SlideShare a Scribd company logo
XII CBSE
Previous Year
Question Paper
QUESTION NO
2 (a)
2 Marks
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
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
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))
2. (a) Differentiate between Protected and
Private members of a class in context of
Inheritance using C++. Delhi 2007 2
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.
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.
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)
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).
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;
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
}
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)
Outside Delhi 2008 2
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.
//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; }
Play:: Play (Play &P) //copy constructor
{
Count=P.Count+l0;
Number=P.Number+20;
}
void Play::Disp()
{
cout<<Count;
cout<<Number<<endl;
}
void Play::Change(int C,int N)
{
Count=C;
Number=N; }
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
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.
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;
}
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)
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.
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; }
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
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)
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.
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();
};
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)
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.
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;
} };
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
} } ;
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)
Outside
Delhi 2011
Outside Delhi 2011
SAMPLE PAPER SET I 2012
SAMPLE PAPER SET II 2012
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.
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();
};
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)
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.
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; }
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
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)
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.
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
(½ 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
THAN
K
YOU

More Related Content

What's hot

Introduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutletIntroduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutletOldingz
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceIt Academy
 
Support for Object-Oriented Programming (OOP) in C++
Support for Object-Oriented Programming (OOP) in C++Support for Object-Oriented Programming (OOP) in C++
Support for Object-Oriented Programming (OOP) in C++Ameen Sha'arawi
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationCoen De Roover
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Abou Bakr Ashraf
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++Mohamad Al_hsan
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingRenas Rekany
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Abou Bakr Ashraf
 

What's hot (20)

java tutorial 3
 java tutorial 3 java tutorial 3
java tutorial 3
 
Introduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutletIntroduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutlet
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
 
Oop l2
Oop l2Oop l2
Oop l2
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class Inheritance
 
Support for Object-Oriented Programming (OOP) in C++
Support for Object-Oriented Programming (OOP) in C++Support for Object-Oriented Programming (OOP) in C++
Support for Object-Oriented Programming (OOP) in C++
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Inheritance
InheritanceInheritance
Inheritance
 
05. inheritance
05. inheritance05. inheritance
05. inheritance
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
 
Java basic understand OOP
Java basic understand OOPJava basic understand OOP
Java basic understand OOP
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 
Object Oriented Programming using C++ - Part 1
Object Oriented Programming using C++ - Part 1Object Oriented Programming using C++ - Part 1
Object Oriented Programming using C++ - Part 1
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
147301 nol
147301 nol147301 nol
147301 nol
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8
 

Viewers also liked (20)

8 Pointers
8 Pointers8 Pointers
8 Pointers
 
6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
 
Qno 2 (b)
Qno 2 (b)Qno 2 (b)
Qno 2 (b)
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
Qno 1 (b)
Qno 1 (b)Qno 1 (b)
Qno 1 (b)
 
Qno 1 (f)
Qno 1 (f)Qno 1 (f)
Qno 1 (f)
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
Qno 1 (c)
Qno 1 (c)Qno 1 (c)
Qno 1 (c)
 
Qno 1 (a)
Qno 1 (a)Qno 1 (a)
Qno 1 (a)
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
Qno 2 (c)
Qno 2 (c)Qno 2 (c)
Qno 2 (c)
 
Qno 3 (a)
Qno 3 (a)Qno 3 (a)
Qno 3 (a)
 
9 Arrays
9 Arrays9 Arrays
9 Arrays
 
Computer Overview
Computer OverviewComputer Overview
Computer Overview
 
10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and Queues10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and Queues
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
Structures
StructuresStructures
Structures
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 

Similar to Qno 2 (a)

C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And AnswerJagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objectsRai University
 
C questions
C questionsC questions
C questionsparm112
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answersAkash Gawali
 
OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ Dev Chauhan
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)rashmita_mishra
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorialsakreyi
 
+2 CS class and objects
+2 CS class and objects+2 CS class and objects
+2 CS class and objectskhaliledapal
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++Swarup Boro
 
Qno1
Qno1Qno1
Qno1kvs
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classesrsnyder3601
 

Similar to Qno 2 (a) (20)

C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objects
 
Object & classes
Object & classes Object & classes
Object & classes
 
C questions
C questionsC questions
C questions
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++ OBJECT ORIENTED PROGRAMING IN C++
OBJECT ORIENTED PROGRAMING IN C++
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2
 
C++ interview question
C++ interview questionC++ interview question
C++ interview question
 
+2 CS class and objects
+2 CS class and objects+2 CS class and objects
+2 CS class and objects
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
 
Qno1
Qno1Qno1
Qno1
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classes
 
Class and object
Class and objectClass and object
Class and object
 

More from Praveen M Jigajinni

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithmsPraveen M Jigajinni
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructorsPraveen M Jigajinni
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programmingPraveen M Jigajinni
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with pythonPraveen M Jigajinni
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingPraveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow chartsPraveen M Jigajinni
 

More from Praveen M Jigajinni (20)

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programming
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinking
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
Chapter 5 boolean algebra
Chapter 5 boolean algebraChapter 5 boolean algebra
Chapter 5 boolean algebra
 
Chapter 4 number system
Chapter 4 number systemChapter 4 number system
Chapter 4 number system
 

Recently uploaded

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chipsGeoBlogs
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfYibeltalNibretu
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 

Recently uploaded (20)

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 

Qno 2 (a)

  • 1. XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks
  • 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; }
  • 16. Play:: Play (Play &P) //copy constructor { Count=P.Count+l0; Number=P.Number+20; } void Play::Disp() { cout<<Count; cout<<Number<<endl; } void Play::Change(int C,int N) { Count=C; Number=N; }
  • 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)
  • 35. SAMPLE PAPER SET II 2012
  • 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