460 likes | 620 Views
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.
E N D
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) B A 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)
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)
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.
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 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)