1. Data encapsulation refers to wrapping up data and functions together in a class. Data hiding keeps data private to prevent accidental changes and only accessible by member functions.
2. Private members are only accessible by member functions of the class, while public members are accessible by member functions of the class and derived classes, as well as by objects of the class.
3. An example class illustrates that a private member cannot be accessed directly by a derived class, while a public member function of the base class can be called by the derived class.
2. 2. (a) Define Multilevel and Multiple inheritance
in context of Object Oriented Programming.
Give suitable example to illustrate the same.
Delhi 2006 2
2. (a) In Multilevel inheritance, a class inherits it’s
properties from another derived class transitively.
A
B
C
3. In Multiple inheritance, a derived class inherits
from multiple base classes.
(1/2 mark each for any correct definition)
(1/2 mark each for any correct example – diagrammatic/
C++ representation)
OR
(Full 2 marks for explaining the 2 types of inheritance with
the help of suitable examples or diagram)
A B
C
4. 2. (a) What is “this” pointer ? Give an
example to illustrate the use of it in C++.
Outside Delhi 2006 2
2. (a) Students are exposed to the concept of
pointers, but not exposed specifically to the
concept of “this” pointer. So benefit of doubt
should be given to the students.
(Full 2 marks to be given to students who
have correctly attempted for at least 1 mark
in the entire Q. No. 2 (a) to 2 (d))
5. 2. (a) Differentiate between Protected and
Private members of a class in context of
Inheritance using C++. Delhi 2007 2
6. 2. (a) Differentiate between Constructor and
Destructor function in context of Classes and
Objects using C++ OD 2007 2
2. (a) Constructors:
· Name of the constructor functions is same
as the name of the class
· No return type required for constructor
function.
· Constructor functions are called
automatically at the time of creation of the
object
· Constructors can be overloaded
· Constructor functions are defined in public.
7. 2. (a) Differentiate between Constructor and
Destructor function in context of Classes and
Objects using C++ OD 2007 2
2. Destructors:
· Name of the destructor is same as the
name of the class preceded by ~
· No return type required for destructor
function.
· Destructor functions are called automatically
when the scope of the object gets over
· Destructor can not be overloaded
· Destructor function is defined in public.
8. 2. (a) Differentiate between Constructor and
Destructor function in context of Classes and
Objects using C++ OD 2007 2
(1 Mark for correct explanation of Constructor)
(1 Mark for correct explanation of Destructor)
OR
(1 Mark for any valid example of a Constructor)
(1 Mark for any valid example of a Destructor)
9. 2. (a) Differentiate between public and private
visibility modes in context of Object Oriented
Programming using a suitable example
illustrating each. Delhi 2008 2
Ans: PUBLIC VISIBILITY MODE:
Members of a class declared under this visibility are
accessible inside the class (in member functions of
the class) as well as by the Objects of that class
(in any non member function of the program,
prototyped / defined after the class declaration).
10. 2. (a) Differentiate between public and private
visibility modes in context of Object Oriented
Programming using a suitable example
illustrating each. Delhi 2008 2
Ans: PRIVATE VISIBILITY MODE:
Members of a class declared under this visibility are
accessible only inside the class (in member functions
of the class). They can not be accessed outside
the class.
class Example
{
int Priv;
11. 2. (a) Differentiate between public and private
visibility modes in context of Object Oriented
Programming using a suitable example
illustrating each. Delhi 2008 2
void Assign ( )
{
Priv =10; //private member accessible only inside class
}
} ;
void main ( )
{
Example E;
E.Assign( ); //public member accessible by Object
}
12. 2. (a) Differentiate between public and private
visibility modes in context of Object Oriented
Programming using a suitable example
illustrating each. Delhi 2008 2
(2 Marks for differentiating public and private correctly
using suitable example)
OR
(1 Mark for correct explanation of private visibility)
(1 Mark for correct explanation of public visibility)
OR
(1 Mark for any valid example of a private member of
a class)
(1 Mark for any valid example of a public member of a
class)
14. 2. (a) What is copy constructor? Give an
example in C++ to illustrate copy constructor.
Delhi 2009 2
Ans A copy constructor is an overloaded
constructor function in which (an) object(s) of
the same class is/are passed as a reference
parameter(s). It is used when an object’s data
value is related to or is initialised using another
object’s data value of the same class. In the
example below the values of data members of
object Q are dependent on the values of data
members of object P and Data members of
object R dependent on Q.
15. //Example of Copy Constructor
class Play
{
int Count, Number;
public:
Play(); //constructor
Play(Play &);//copy constructor
void Disp();
void Change(int,int);
};
Play::Play () //constructor
{
Count=0;
Number=0; }
17. void main ()
{
Play P; //Call for constructor
P.Disp (); P.Change(90,80) ;
Play Q(P); //Copy constructor call
Q.Disp();
Play R=Q; //Copy constructor ca11 [same as P1ay
R(Q);]
R. Disp();
}
(1 Mark for correct explanation of Copy Constructor)
(1 Mark for a valid example of Copy Constructor)
Note: Member function other than the constructors
are optional
18. 2. (a) What is function overloading? Give an
example in C++ to illustrate function
overloading. Outside Delhi 2
Ans Function overloading is an example of
polymorphism, where the functions having
same name with different set of parameters
perform different operations.
OR
When a function is having more than one
definition and differentiable by the
number/type of parameters is known as
function overloading.
19. 2. (a) What is function overloading? Give an
example in C++ to illustrate function
overloading. Outside Delhi 2
Example:
void Disp() //Function 1
{
cout<<”Hello”<<endl;
}
void Disp(int N) // Function 2
{
for (int I=1;I<=N;I++)
cout<<I<<end1;
}
20. 2. (a) What is function overloading? Give an
example in C++ to illustrate function
overloading. Outside Delhi 2
(1 Mark for correct definition or explanation of
Function Overloading)
(1 Mark for a valid example of Function
Overloading)
21. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
Delhi 2010 2
Ans. The process of using an -operator or a
function in different ways for different set of inputs
given is known- as polymorphism. Function
overloading is- an example of polymorphism,
where the functions having same name with
different set of parameters perform different
operations.
22. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
Delhi 2010 2
Example:
void Disp ( ) //Function 1
{
cout<<“Hello”<<endl;
}
void Disp(int N) //Function 2
{
for(int I=1;I<=N;I++)
cout<<I<<endl; }
23. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
Delhi 2010 2
void Disp (int N,int M) //Function 3
{
for (int I=N;I<=M; I++)
cout<<N<<“x”<<I<<“=”<<N*I<<endl;
}
void main ( )
{
int x=5, y=10;
Disp(x); //Function 2 called-Prints numbers from 1 to 5
24. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
Delhi 2010 2
Disp(x,y) ; //Function 3 called- Prints from
multiples of 5 ranging from 5 to 10
Disp () ; //Function 1 called- Prints Hello
}
(1 Mark for correct explanation of Polymorphism)
(1 Mark for a valid example of Polymorphism)
25. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 2
Ans. Data Encapsulation: Wrapping up of data
and functions together in a single unit is known as
Data Encapsulation. In a class, we wrap up the
data and functions together in a single unit.
Data Hiding: Keeping the data in
private/protected visibility mode of the class to
prevent it from accidental change is known as
Data Hiding.
26. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 2
class Computer
{
char CPU[lO] ;int RNM; //Data Hiding
public: //Data Encapeulation
void STOCK();
void SHOW();
};
27. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 2
(½ Mark for each correct explanation of Data
Encapsulation and Data Hiding)
(½ Marks for each correct example of Data
Encapsulation and Data Hiding)
OR
(2 Marks for explaining the concept of the terms
through suitable examples)
OR
(Only 1 Mark to be awarded for Explanation given
without any example)
28. 2. (a) Differentiate between members, which
are present within the private visibility mode
with those which are present within the public
visibility modes. Delhi 2011 2
Ans Private members of a class are
accessible only to the member functions of the
same class.
Public members of a class are accessible to
the member functions of the same class as
well as member functions of its derived
class(es) and also to an object of the class.
29. 2. (a) Differentiate between members, which
are present within the private visibility mode
with those which are present within the public
visibility modes. Delhi 2011 2
class Base
{
int N;
public:
void Assign ()
{
N=10;
} };
30. 2. (a) Differentiate between members, which
are present within the private visibility mode
with those which are present within the public
visibility modes. Delhi 2011 2
class Derived: public Base
{
int X;
public:
void DisplayBase()
{
cout<<N; //Not Accessible
Assign ( ) ; //Accessible
} } ;
31. 2. (a) Differentiate between members, which
are present within the private visibility mode
with those which are present within the public
visibility modes. Delhi 2011 2
void main ( )
{
Base B;
B.Assign( ) ; //Accessible
}
(1 Mark for correct explanation OR example illustrating non
accessibility of Private Members inside Derived class)
(1 Marks for correct explanation OR example illustrating
accessibility of Public Members inside Derived Class and to
object of the class)
36. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 SAMPLE PAPER 2009 SET I 2
Ans. Data Encapsulation: Wrapping up of data
and functions together in a single unit is known as
Data Encapsulation. In a class, we wrap up the
data and functions together in a single unit.
Data Hiding: Keeping the data in
private/protected visibility mode of the class to
prevent it from accidental change is known as
Data Hiding.
37. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 SAMPLE PAPER 2009 SET I 2
class Computer
{
char CPU[lO] ;int RNM; //Data Hiding
public: //Data Encapeulation
void STOCK();
void SHOW();
};
38. 2. (a) What do you understand by Data
Encapsulation and Data Hiding ?’ Also, give
an example in C++ to illustrate both.
Outside Delhi 2010 SAMPLE PAPER 2009 SET I 2
(½ Mark for each correct explanation of Data
Encapsulation and Data Hiding)
(½ Marie for each correct example of Data
Encapsulation and Data Hiding)
OR
(2 Marks for explaining the concept of the terms
through suitable examples)
OR
(Only 1 Mark to be awarded for Explanation given
without any example)
39. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
SAMPLE PAPER 2009 SET II ,Delhi 2010 2
Ans. The process of using an -operator or a
function in different ways for different set of inputs
given is known- as polymorphism. Function
overloading is- an example of polymorphism,
where the functions having same name with
different set of parameters perform different
operations.
40. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
SAMPLE PAPER 2009 SET II Delhi 2010 2
Example:
void Disp ( ) //Function 1
{
cout<<“Hello”<<endl;
}
void Disp(int N) //Function 2
{
for(int I=1;I<=N;I++)
cout<<I<<endl; }
41. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
Delhi 2010 2
void Disp (int N,int M) //Function 3
{
for (int I=N;I<=M; I++)
cout<<N<<“x”<<I<<“=”<<N*I<<endl;
}
void main ( )
{
int x=5, y=10;
Disp(x); //Function 2 called-Prints numbers from 1 to 5
42. 2. (a) What do you understand by
Polymorphism.? Also, give an example in C++
to illustrate the same. .
SAMPLE PAPER 2009 SET II, Delhi 2010 2
Disp(x,y) ; //Function 3 called- Prints from
multiples of 5 ranging from 5 to 10
Disp () ; //Function 1 called- Prints Hello
}
(1 Mark for correct explanation of Polymorphism)
(1 Mark for a valid example of Polymorphism)
43. 2. (a) What do you understand by Data Encapsulation and
Data Hiding ?’ Also, give an example in C++ to illustrate
both. 2
Outside Delhi 2010, SAMPLE PAPER 2009 SET I,
SAMPLE PAPER 2010 SET I
Ans. Data Encapsulation: Wrapping up of data
and functions together in a single unit is known as
Data Encapsulation. In a class, we wrap up the
data and functions together in a single unit.
Data Hiding: Keeping the data in
private/protected visibility mode of the class to
prevent it from accidental change is known as
Data Hiding.
44. class Computer
{
char CPU[lO] ;int RNM; //Data Hiding
public: //Data Encapeulation
void STOCK();
void SHOW();
};
2. (a) What do you understand by Data Encapsulation and
Data Hiding ?’ Also, give an example in C++ to illustrate
both. 2
Outside Delhi 2010, SAMPLE PAPER 2009 SET I,
SAMPLE PAPER 2010 SET I
45. (½ Mark for each correct explanation of Data
Encapsulation and Data Hiding)
(½ Marie for each correct example of Data
Encapsulation and Data Hiding)
OR
(2 Marks for explaining the concept of the terms
through suitable examples)
OR
(Only 1 Mark to be awarded for Explanation given
without any example)
2. (a) What do you understand by Data Encapsulation and
Data Hiding ?’ Also, give an example in C++ to illustrate
both. 2
Outside Delhi 2010, SAMPLE PAPER 2009 SET I,
SAMPLE PAPER 2010 SET I