xii cbse previous year question paper question no 2 (a) 2 marks

46
XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

Upload: kelley-ellis

Post on 23-Dec-2015

235 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

XII CBSE Previous Year Question

Paper

QUESTION NO 2 (a)

2 Marks

Page 2: 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

Page 3: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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

Page 4: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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))

Page 5: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

2. (a) Differentiate between Protected and Private members of a class in context of Inheritance using C++. Delhi 2007 2

Page 6: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

2. (a) Differentiate between Constructor and Destructor function in context of Classes and Objects using C++ OD 2007 22. (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.

Page 7: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 8: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 9: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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).

Page 10: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 outsidethe class.class Example{int Priv;

Page 11: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

2. (a) Differentiate between public and private visibility modes in context of Object Oriented Programming using a suitable example illustrating each. Delhi 2008 2void Assign ( ){Priv =10; //private member accessible only inside class

}} ;void main ( ){Example E;E.Assign( ); //public member accessible by Object}

Page 12: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 13: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

Outside Delhi 2008 2

Page 14: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

2. (a) What is copy constructor? Give an example in C++ to illustrate copy constructor.

Delhi 2009 2Ans 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 anotherobject’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.

Page 15: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

//Example of Copy Constructorclass Play{int Count, Number;public:Play(); //constructorPlay(Play &);//copy constructorvoid Disp();void Change(int,int);};Play::Play () //constructor{Count=0;Number=0; }

Page 16: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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; }

Page 17: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

void main (){Play P; //Call for constructorP.Disp (); P.Change(90,80) ;Play Q(P); //Copy constructor callQ.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

Page 18: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

ORWhen a function is having more than one definition and differentiable by the number/type of parameters is known as function overloading.

Page 19: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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;}

Page 20: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 21: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 22: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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; }

Page 23: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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

Page 24: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 10Disp () ; //Function 1 called- Prints Hello}(1 Mark for correct explanation of Polymorphism)(1 Mark for a valid example of Polymorphism)

Page 25: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 26: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 Hidingpublic: //Data Encapeulationvoid STOCK();void SHOW();};

Page 27: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 28: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 29: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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;} };

Page 30: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 2class Derived: public Base{int X;public:void DisplayBase(){cout<<N; //Not AccessibleAssign ( ) ; //Accessible} } ;

Page 31: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 32: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

Outside Delhi 2011

Page 33: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

Outside Delhi 2011

Page 34: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

SAMPLE PAPER SET I 2012

Page 35: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

SAMPLE PAPER SET II 2012

Page 36: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 37: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 Hidingpublic: //Data Encapeulationvoid STOCK();void SHOW();};

Page 38: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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)

Page 39: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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.

Page 40: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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; }

Page 41: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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

Page 42: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

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 10Disp () ; //Function 1 called- Prints Hello}(1 Mark for correct explanation of Polymorphism)(1 Mark for a valid example of Polymorphism)

Page 43: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

2. (a) What do you understand by Data Encapsulation and Data Hiding ?’ Also, give an example in C++ to illustrate both. 2Outside 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.

Page 44: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

class Computer{char CPU[lO] ;int RNM; //Data Hidingpublic: //Data Encapeulationvoid STOCK();void SHOW();};

2. (a) What do you understand by Data Encapsulation and Data Hiding ?’ Also, give an example in C++ to illustrate both. 2Outside Delhi 2010, SAMPLE PAPER 2009 SET I, SAMPLE PAPER 2010 SET I

Page 45: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

(½ 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. 2Outside Delhi 2010, SAMPLE PAPER 2009 SET I, SAMPLE PAPER 2010 SET I

Page 46: XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks

THANK YOU