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

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Chapter 4 Constructors and Destructors. Objectives Constructors – introduction and features The zero-argument constructor Parameterized constructors Creating.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Question answers on constructor and destructor and class and object Pournomi Sen PGT,Comp Sc K.V Ballygunge.
Road Map Introduction to object oriented programming. Classes
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
Chapter Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Definition Class In C++, the class is the construct primarily used to create objects.
Lecture From Chapter 6 & /8/10 1 Method of Classes.
XII CBSE Previous Year Question Paper QUESTION NO 2 (a) 2 Marks.
Learners Support Publications Pointers, Virtual Functions and Polymorphism.
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
XII CBSE Previous Year Question Paper QUESTION NO 2 (c) 4 Marks.
XII CBSE Previous Year Question Paper QUESTION NO 1 (a) 1 OR 2 Marks.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Copyright  Hannu Laine C++-programming Part 3 Hannu Laine.
Lecture # 8 Constructors Overloading. Topics We will discuss the following main topics: – Static Class Members – Overloaded Methods – Overloaded Constructors.
CHAPTER 5 FUNCTIONS I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
CONSTRUCTORS AND THEIR TYPES. Prepared by. MURLI MANOHAR. PGT (COMP
CPS120: Introduction to Computer Science Functions.
Chapter 10 Introduction to Classes
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
CPS120: Introduction to Computer Science Lecture 14 Functions.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Built-In and user-Defined functions Software Design Concepts Lecture IV Dr. Sothy Vignarajah.
CONSTRUCTORS AND DESTRUCTORS Chapter 5 By Mrs. Suman Verma PGT (Comp.Sc)
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
XII CBSE Previous Year Question Paper QUESTION NO 1 (b) 1 OR 2 Marks.
XII CBSE Previous Year Question Paper QUESTION NO 2 (d) 4 Marks.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
1 CSC241: Object Oriented Programming Lecture No 02.
2 Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Manish K Parmar PGT (CS) K V VVNagar Thursday, December 24, 2015 Lesson on USER DEFINED FUNCTION IN C++ Presented by Manish K Parmar PGT Computer Science.
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
CONSTRUCTOR AND DESTRUCTORS
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 15 Inheritance.
Chapter -6 Polymorphism
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Introduction to Programming Lecture 40. Class Class is a user defined data type.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
XII CBSE Previous Year Question Paper QUESTION NO 1 (F) 2 or 3 Marks.
Methods Awesomeness!!!. Methods Methods give a name to a section of code Methods give a name to a section of code Methods have a number of important uses.
CONSTRUCTOR AND DESTRUCTOR. Topics to be discussed……………….. 1. Introduction Introduction 2. FeaturesFeatures 3. Types of ConstructorTypes of Constructor.
Programming Fundamentals1 Chapter 7 INTRODUCTION TO CLASSES.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Computer Programming II Lecture 4. Functions - In C++ we use modules to divide the program into smaller and manageable code. These modules are called.
Chapter 6 Modularity Using Functions
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 4th Edition.
Introduction to C++ programming Recap- session 1 Structure of C++ program Keywords Operators – Arithmetic – Relational – Logical Data types Classes and.
XII CBSE Previous Year Question Paper QUESTION NO 1 (D) 2 or 3 Marks.
Static data members Constructors and Destructors
Constructors & Destructors.
Chapter 5 Classes.
Constructor & Destructor
group work #hifiTeam
Prepared by Puttalakshmi H.R PGT(CS) KV Minambakkam Chennai-27.
Constructor & Destructor
CONSTRUCTOR A member function with the same name as its class is called Constructor and it is used to initialize the objects of that class type with.
CONSTRUCTORS AND DESRUCTORS
Method of Classes Chapter 7, page 155 Lecture /4/6.
Chapter 11 Classes.
Constructors & Destructors
Presentation transcript:

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 }; (i) Create an object, such that it invokes Constructor 1 1 (ii) Write complete definition for Constructor 2 1

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

(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

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

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

(b) Answer the questions (i) and (ii) after going through the following class: Delhi ~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 ?

(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

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

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

(b) Answer the questions (i) and (ii) after going through the following class Outside Delhi { ~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?

(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

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

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

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

(b) Answer the questions (i) and (ii) after going through the following program Delhi 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)

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)

If the constructor is defined as a public member, the following output shall be generated: (1 Mark for correct answer) OR (½ Mark each for the String and Numeric values)

(b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi #include class Retail { char Category [20]; char Item [20]; int Qty; float Price;

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

(b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi } }; void main ( ) { Retail R; // Function 1 R. Show ( ) ;. // Function 2 }

(b) Answer the questions (i) and (ii) after going through the following program: Outside Delhi (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)

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)

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

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

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

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?

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)

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

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

(b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi (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?

(b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi (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?

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?

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

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

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

(b) Answer the questions (i) and (ii) after going through the following class: Delhi 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?

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)

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

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

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

(b) Answer the questions (i) and (ii) after going through the following class: Outside Delhi20092 (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?

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)

(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 #include void Print ( ) // Function [I] { for (int K=1 ; K<=60 ; K++) cout<< "-" ; cout<<end1 ; }

(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 void Print (int N) // Function [II] { for (int K=1 ; K<=N ; L++) cout<<"*" ; cout<<end1 ; }

(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 void Print (int A, int.B) // Function [III] { for (int K=1. ;K<=B ;K++) cout <<A*K ; cout<<end1 ; }

(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 void Print (char T, int N) // Function [IV] { for (int K=1 ; K<=N ; K++) cout<<T ; cout<<end1; }

(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 void main ( ) { int U=9, V=4, W=3; char ; Print (C,V) ; Print (U,W) ; }

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

(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 #include void Line ( ) //Function [I] { for (int L=1;L<=80;L++) cout<<"-"; cout<<end1; }

(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 void Line (int N) //Function[II] { for (int L=l;L<=N;L++) Cout<<"*"; cout<<endl; }

(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 void Line (char C, int N) //Function [III] { for (int L=l;L<=N;L++) cout<<C; cout<<endl; }

(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 void Line (int M, int, N) //Function [IV] { for (int L=1;L<=N;L++) cout<<M*L; cout<<end1; }

(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 void main ( ) { int A=9, B=4, C=3; char K= '#' ; Line (K,B); Line (A,C); }

Ans #### Polymorphism OR Function Overloading (½ Mark for writing each correct line of output) (1 Mark for writing the feature. name correctly)

(b) Answer the questions (i) and (ii) after going through the following class: Sample Paper 2010 SET I 2 class Seminar { int Time; public: Seminar() //Function 1 { Time=30;cout<<"Seminar starts now"<<end1; }

(b) Answer the questions (i) and (ii) after going through the following class: Sample Paper 2010 SET I 2 void Lecture() //Function 2 { cout<<"Lectures in the seminar on"<<end1; } Seminar(int Duration) //Function 3 { Time=Duration;cout<<"Seminar starts now"<<end1; }

(b) Answer the questions (i) and (ii) after going through the following class: Sample Paper 2010 SET I 2 ~Seminar() //Function 4 { cout<<"Vote of thanks"<<end1; } }; i) In Object Oriented Programming, what is Function 4 referred as and when does it get invoked/called?

(b) Answer the questions (i) and (ii) after going through the following class: Sample Paper 2010 SET I 2 ii) In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3 together? Write an example illustrating the calls for these functions.

(b) i) Destructor, it is invoked as soon as the scope of the object gets over. 2 ( ½ Mark for mentioning destructor) ( ½ Mark for remaining answer) ii) Constructor Overloading (or Function Overloading or Polymorphism) Seminar S1; //Function 1 Seminar S2(90); //Function 3 ( ½ Mark for mentioning the correct concept) ( ½ Mark for the example)

(b) Answer the questions (i) and (ii) after going through the following program: SAMPLE PAPER 2010 SET II2 class Match { int Time; public: Match() //Function 1 { Time=0; cout<<"Match commences"<<end1; }

(b) Answer the questions (i) and (ii) after going through the following program: SAMPLE PAPER 2010 SET II2 void Details() //Function 2 { cout<<"Inter Section Basketball Match"<<end1; } Match(int Duration) //Function 3 { Time=Duration; cout<<"Another Match begins now"<<end1; }

(b) Answer the questions (i) and (ii) after going through the following program: SAMPLE PAPER 2010 SET II2 Match(Match &M) //Function 4 { Time=M.Duration; cout<<"Like Previous Match "<<end1; } }; i) Which category of constructor - Function 4 belongs to and what is the purpose of using it? ii) Write statements that would call the member Functions 1 and 3

(b) i)Copy constructor, It will help to copy the data from one object to another. ( ½ Mark for mentioning copy constructor) ( ½ Mark for remaining answer) ii) Match M; //Function 1 Match N(10); //Function 3 ( ½ Mark for each statement)

SAMPLE PAPER 2012 SET I2

SAMPLE PAPER 2012 SET II2

THANK YOU