1 / 71

XII CBSE Previous Year Question Paper

XII CBSE Previous Year Question Paper. QUESTION NO 2 (b) 2 Marks. 2 (b) Answer the questions (i) and (ii) after going through the following class : Delhi 2006 class Interview { int month; public: Interview(int y) {month=y;} //Constructor 1 Interview(Interview&t); //Constructor 2 };

shira
Télécharger la présentation

XII CBSE Previous Year Question Paper

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XII CBSE Previous Year Question Paper QUESTION NO 2 (b) 2 Marks

  2. 2 (b) Answer the questions (i) and (ii) after going through the following class : Delhi 2006 class Interview { int month; public: Interview(int y) {month=y;} //Constructor 1 Interview(Interview&t); //Constructor 2 }; (i) Create an object, such that it invokes Constructor 1 1 (ii) Write complete definition for Constructor 2 1

  3. (b) Interview Ob1(5); OR int N=5; Interview Ob1(N); (1 mark for proper declaration of Object) Interview(Interview &t) { month = t.month; } (1 mark for writing proper statements inside definition of Constructor 2) OR (1 mark for writing the conceptual definition of the copy constructor) OR (Only ½ mark for mentioning the term: copy constructor) Note: Any valid statement in C++ working with t as an object of Interview must be accepted while defining the constructor.

  4. (b) Answer the questions (i) and (ii) after going through the following class : Outside Delhi 2006 class Exam { int year; public: Exam(int y) { year=y;} //Constructor 1 Exam(Exam & t); //Constructor 2 }; (i) Create an object, such that it invokes Constructor 1. 1 (ii) Write complete definition for Constructor 2. 1

  5. (ii) Exam (Exam &t) {year = t.year;} OR Copy constructor: It is an overloaded constructor, in which object of the same class is passed as parameter. (1 mark for writing proper statements inside definition of Constructor 2) OR (1 mark for any valid statement in C++ working with t as an object of Exam) OR (1 mark for writing the definition/explanation of the concept of copy constructor) OR (1/2 mark for mentioning only the term copy constructor)

  6. (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2007 2 class Science { char Topic[20]; int Weightage; public: Science ( ) //Function 1 { strcpy (Topic, “Optics” ); Weightage = 30; cout<<“Topic Activated”; }

  7. (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2007 2 ~Science( ) //Function 2 { cout’<<”Topic Deactivated”; } (i) Name the specific features of class shown by Function 1 and Function 2 in the above example. (ii) How would Function 1 and Function 2 get executed ?

  8. (b) (i) Function 1: Constructor/ Default Constructor Function 2: Destructor (½ Marks for each correct answer) (ii) Function 1 is executed or invoked automatically when an object of class Science is created. Function 2 is invoked automatically when the scope of an object of class Science comes to an end. OR

  9. (b) Example: { Science s1;//Constructor is invoked } // the destructor is invoked (½ Mark for each correct answer through explanation OR example)

  10. (b) Answer the questions (i) and (ii) after going through the following class Outside Delhi 2007 2 class Maths { char Chapter [20]; int Marks; public: Maths ( ) //Member Function 1 { strcpy (Chapter, “Geometry”); Marks = 10; cout<<“Chapter Initialised”;

  11. (b) Answer the questions (i) and (ii) after going through the following class Outside Delhi 2007 2 { ~Math () //Member Function 2 } cout<<”Chapter Over”; } }; (i) Name the specific features of class shown by Member Function 1 and Member Function 2 in the above example. (ii) How would Member Function 1 and Member Function 2 get executed?

  12. (b) (i) Function 1: Constructor OR Default Constructor Function 2: Destructor (½ Marks for each correct answer) (ii) Function 1 is executed or invoked automatically when an object of class Maths is created. Function 2 is invoked automatically when the scope of an object of class Maths comes to an end. OR

  13. (b) Example: { Maths s1; //Constructor is invoked } //Destructor is invoked (½ Mark for each correct answer through explanation OR example) NOTE: If the error in declaration of the destructor is specified then marks for the destructor function should be allocated.

  14. (b) Answer the questions (i) and (ii) after going through the following program Delhi 2008 2 #include<iostream.h> #include<string.h> class Bazar { char Type[20]; char Product[20]; int Qty; float Price; Bazar ( ) //Function 1 { strcpy (Type, “Electronic”);

  15. (b) Answer the questions (i) and (ii) after going through the following program Delhi 2008 2 strcpy (Product, “Calculator”); Qty=10; Price=225; } public: void Disp ( ) / / Function 2 { cout<<Type<<“-”<<Product<<“:”<<Qty <<“@” <<Price<<endl; } };

  16. (b) Answer the questions (i) and (ii) after going through the following program Delhi 2008 2 void main ( ) { Bazar B; / /Statement 1 B. Disp ( ); / / Statement 2 } (i) Will Statement 1 initialize all the data members for object B with the values given in the Function I? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code. (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the program)

  17. Ans: No, since the constructor Bazar has been defined in private section Suggested Correction: Constructor Bazar() to be , defined in public (½ Mark for identifying NO) (½ Mark for justification and correction) (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the Program)

  18. If the constructor is defined as a public member, the following output shall be generated: Electronic-Calculator:10@225 (1 Mark for correct answer) OR (½ Mark each for the String and Numeric values)

  19. (b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi 2008 2 #include<iostream.h> #include<string.h> class Retail { char Category [20]; char Item [20]; int Qty; float Price;

  20. (b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi 2008 2 Retail ( ) // Function 1 { strcpy (Category, “Cereal”); strcpy (Item, “Rice”); Qty = 100; Price = 25; public: void Show ( ) // Function 2 { cout<<Category<<“–”<<Item<<“ : ”<<Qty

  21. (b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi 2008 2 <<“@”<<Price<<endl; } }; void main ( ) { Retail R; // Function 1 R. Show ( ) ;. // Function 2 }

  22. (b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi 2008 2 (i) Will Statement 1 initialize all the data members for object R with the values given in the Function 1 ? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code. (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the program)

  23. Ans: i) No, since the constructor Retail has been defined in private section. Suggested Correction: Constructor RetailO to be defined in public section of class. (½ mark for identifying No) (½ mark for justification)

  24. 2 (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 class WORK 2 { int WorkId;char WorkType ; public: -WORK ( ) //Function 1 { cout<<”Un-Allocated”<<endl ;} void status ( ) //Function 2 { cout<<WorkId<<”: “<<WorkType<<endl ;} WORK ( ) //Function 3

  25. 2 (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 { WorkId = 10; WorkType=’T’ ; } WORK(WORK &W) //Function 4 { WorkId=W. WorkId+12;WorkType=W. WorkType+l } } ;

  26. 2 (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 (i) Which member function out of Function 1, Function 2, Function 3 and Function 4 shown in the above definition of class WORK is called automatically, when the scope of an object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor? (ii) WORK W ; //Statement 1 WORK Y (W) ; //Statement 2

  27. 2 (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 Which member function out of Function 1, Function 2, Function 3 and Function4 shown in the above definition of class WORK will be called on execution of statement written as statement 2 ? What is this function specifically known as out of Destructor or Copy Constructor or Default Constructor?

  28. Ans Function 1 Destructor. (½ Mark for naming Function 1 correctly) (½ Mark for naming it as Destructor, (ii) WORK W; // Statement 1 WORK Y(W); // Statement 2 Which member function out of Function 1, Function 2, Function 3 and Function4 shown in the above definition of class WORK will be called on execution of statement written as statement 2 ? What is this function specifically known as out of Destructor or Copy Constructor or Default Constructor? Ans Function 4 Copy Constructor. (½ Mark for naming Function 4 correctly) (½ Mark for naming it as Copy Constructor)

  29. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 class Job { int JobId;char JobType; public: ~Job ( ) //Function 1 { cout<< “Resigned” <<end1; } Job ( ) //Function 2 { JobId=10 ; JobType =‘T” ;}

  30. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 void TellMe( )//Function 3 { cout<<JobId<< “: ” <<JobType<<end1; } Job (Job &J) //Function 4 { JobId=J.JobId+10; JobType=J.JobType+l; } };

  31. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 (i) Which member function out of Function 1, Function 2, Function 3 and Function 4 shown in the above definition of class Job is called automatically, when the scope of an object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor?

  32. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 (ii) Job P ; //Line 1 Job Q(P) ; //Line 2 Which member function out of Function 1, Function 2, Function 3 and Function 4 shown in the above definition of class Job will be called on execution of statement written as Line 2 ? What is this function specifically known as out of Destructor or Copy Constructor or Default Constructor?

  33. Ans Function 1. Destructor. ( ½ Mark for mentioning the correct function) ( ½ Mark for identifying it as Destructor) (ii) Job P ; //Line 1 Job Q(P) ; //Line 2 Which member function out of Function 1, Function 2, Function 3 and Function4 shown in the above definition of class Job will be called on execution of statement written as Line 2 ? What is this function specifically known as out of Destructor or Copy Constructor or Default Constructor?

  34. Ans Function 4. Copy Constructor. ( ½ Mark for mentioning the correct function) ( ½ Mark for identifying it as Copy constructor)

  35. (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 2 class TEST { int Regno, Max, Min, Score; public: TEST() //Function 1 { Regno= 101;Max=100;Min=40;Score=75; }

  36. (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 2 TEST(int Pregno,int Pscore) //Function 2 { Regno=Pregno; Max=100; Min=40; Score=Pscore; } ~TEST() //Function 3 { cout<<“TEST Over”<<endl; }

  37. (b) Answer the questions (i) and (ii) after going through the following class: Delhi 2009 2 void Display() //Function 4 { cout<<Regno<<“:”<<Max<<“:”<<Min<<endl; cout<<“[Score]”<<Score<<endl; } }; (i) As per Object Oriented Programming, which. concept is illustrated by Function 1 and Function 2 together? (ii) What is Function 3 specifically referred as ? When do you think, Function 3 will be invoked/called?

  38. Ans. i) Polymorphism OR Function Overloading OR Constructor Overloading (1 Mark for naming the concept correctly) (ii) Destructor, invoked or called when scope of an Object gets over. (½ Mark for naming Destructor correctly) (½ Mark for mentioning correctly when it is invoked)

  39. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 class Exam { int Rno,MaxMarks,MinMarks,Marks; public: Exam() //Module 1 { Rno=101; MaxMarks=100; MinMarks=40; Marks=75; }

  40. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 Exam(int Prno, int Pmarks) //Module 2 { Rno=Prno;MaxMarks=l00;MinMarks=40;Marks=Pmarks; } ~Exam() //Module 3 { cout<<“Exam Over”<<endl; }

  41. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 void Show () //Module 4 { cout<<Rno<<“:”<<MaxMarks<<“:”<<MinMarks<<endl; cout<<“[Marks Got]”<<Marks<<endl; } };

  42. (b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi 2009 2 (i) As per Object Oriented Programming, which concept is illustrated by Module 1 and Module 2 together? (ii) What is Module 3 referred as ? When do you think, Module 3 will be invoked/called?

  43. Ans. Polymorphism OR Constructor Overloading OR Function Overloading (1 Mark for mentioning the correct concept) (ii) What is Module 3 referred as ? When do you think, Module 3 will be invoked/called? Ans. Destructor. It is invoked as soon as the scope of the object gets over. (½ Mark for identifying it as Destructor) (½ Mark for mentioning correctly when it be called/invoked)

  44. (b) Write the output of the following C++ code. Also. write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV]. Delhi 2010 2 #include<iostream.h> void Print ( ) // Function [I] { for (int K=1 ; K<=60 ; K++) cout<< "-" ; cout<<end1 ; }

  45. (b) Write the output of the following C++ code. Also. write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV]. Delhi 2010 2 void Print (int N) // Function [II] { for (int K=1 ; K<=N ; L++) cout<<"*" ; cout<<end1 ; }

  46. (b) Write the output of the following C++ code. Also. write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV]. Delhi 2010 2 void Print (int A, int.B) // Function [III] { for (int K=1. ;K<=B ;K++) cout <<A*K ; cout<<end1 ; }

  47. (b) Write the output of the following C++ code. Also. write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV]. Delhi 2010 2 void Print (char T, int N) // Function [IV] { for (int K=1 ; K<=N ; K++) cout<<T ; cout<<end1; }

  48. (b) Write the output of the following C++ code. Also. write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV]. Delhi 2010 2 void main ( ) { int U=9, V=4, W=3; char C='@' ; Print (C,V) ; Print (U,W) ; }

  49. Ans. • @@@@ • 91827 • OR • No Output as L is not declared in void Print (int N) • Polymorphism • OR • Function Overloading • (½ Mark for writing each correct line of output) • (1 Mark for writing the feature name correctly)

  50. (b) Write the output of the following C++ code. Also, write the .name of feature of Object Oriented Programming used in the following program jointly illustrated by the function [I] to [IV] Outside Delhi 2010 2 #include<iostream.h> void Line ( ) //Function [I] { for (int L=1;L<=80;L++) cout<<"-"; cout<<end1; }

More Related