12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Economics Government Budget and the Economy Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Interface Python with MySQL - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Database Concept - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Communication - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Data Structures - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Computer Science Functions - New Previous year Question Papers Study Material - QB365 Set A

Published on: 23/09/2019
Object Oriented Programming in C++
Download CBSE Class 12th Standard CBSE Computer Science question papers, sample papers, important questions, and previous year solved papers in PDF format. Get free study materials, NCERT solutions, and exam preparation resources for Class 12th Standard CBSE Computer Science
Questions + Answers key
Take MCQ Computer Science Test

1.
Define a class named MOVIE in C++ with the following description:
Private members
HALL_NO integer
MOVIE_NAME Array of characters (String)
WEEK integer (Total number of weeks the same movie is shown)
WEEK_COLLECTION Float
TOTAL_COLLECTION Float
Public Members
• Function Read_Data( ) to read an object of ADMISSION type
• Function Display( ) to display the details of an object
• Function Update( ) to update the total collection and Weekly collection once in a week changes. Total collection will be incremented by Weekly collection and Weekly collection is made Zero
2.
Answer the questions (i) to (iv) based on the following code :
class CUSTOMER
{ int Cust_no;
char Cust_Name[20];
protected:
void Register();
public: CUSTOMER();
void Status(); };
class SALESMAN
{
int Salesman_no;
char Salesman_Name[20];
protected: float Salary;
public: SALESMAN();
void Enter( );
void Show( );
};
class SHOP :
private CUSTOMER , public SALESMAN
{
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
}
(iii) Write the names of data members which are accessible from objects belonging to class CUSTOMER.
(iv) Write the names of all the member functions which are accessible from objects belonging to class SALESMAN.
(v) Write the names of all the members which are accessible from member functions of class SHOP. (iv) How many bytes will be required by an object belonging to SHOP?
3.
Define a class TEST in C++ with following description:
Private Members
• TestCode of type integer
• Description of type string
• NoCandidate of type integer
• CenterReqd (number of centers required) of type integer
• A member function CALCNTR() to calculate and return the number of centers as (NoCandidates/100+1) Public Members
• A function SCHEDULE() to allow user to enter values for TestCode, Description, NoCandidate & call function CALCNTR() to calculate the number of Centres
• A function DISPTEST() to allow user to view the content of all the data members
4.
Consider the Following C++ code:
class Data
{
int num;
public:
data(int n)
{
num =n;
}
void show()
{
cout<<"Data Number: "<<num<<end1;
}
};
class Database : public Data
{
char name[12];
int d;
public:
---------------------- //fill in the blanks/
void d show()
{
cout<<"Database Name: "<<name;
cout<<"\ndatabase value: "<<d;
}
};
void main()
{
Database d("SQL",10);
d.show();
d.dshow();
getch();
}
(I) Name the type of inheritance illustrated in the above c++ code.
(ii) Fill in the blanks to define a constructor for the derived class assigning values of the data passedfrom main() and to assign a data 15 to base class construtor data number
(iii) Write the output of the above c++ code
5.
Consider the following and answer the questions given below:
class ITEM
{
char ICode[10];
protected:
char IName[20];
public:
ITEM();
void Enter();
void Display();
};
class SUPPLIER
{
char SCode[10];
protected:
char SName[25];
public:
SUPPLIER();
void TEnter();
void TDisplay();
};
class SHOP : private SUPPLIER, public ITEM
{
char SHOPADDRESS[15],SEmail[25];
public:
SHOP();
void Enter();
void Display();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of all the member functions accessible from Enter() function of class SHOP.
(iii) Write name of all the member functions accessible through an object of class SHOP.
(iv) What will be the order of execution for the constructors ITEM(), SUPPLIER() and SHOP(), when an object of class SHOP is declared?
6.
Consider the following C++ code and answer the questions from (i) to (iv)
class Student
{
int Class, Rno;
char Section;
protected:
char SName[20];
public:
Student();
void Stentry();
void Stdisplay();
};
class Score : private Student
{
float Marks[5];
protected:
char Grade[5];
public:
Score();
void Sentry();
void Sdisplay();
};
class Report : public Score
{
float Total, Avg;
public:
char OverallGrade, Remarks[20];
Report();
void REaluate();
void RPrint();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of class Report.
(iii) Write the names of those member functions, which can be directly accessed from the objects of class Report.
(iv) Write the names of those data members, which can be directly accessd from the Sentry() function of class Score.
7.
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 functions [I] to [IV].
8.
Find the ouptput of the following :
#include< iostream.h >
#include< conio.h >
#include< stdio.h >
#include< string.h >
#include< ctupe.h >
void main( )
{
char *Name= “IntRAneT”;
for(int x =0; x=0;x < strlen(Name);x++)
{
if(islower(Name[x]))
Name[x]=toupper(Name[x]);
{
if(islower(Name[x]))
Name[x]=toupper (Name[x]);
else
if(isupper(Name[x]))
if(x%2==0)
Name[x]=tolower(Name[x]
else
ame[x]=Name[x-1];
}
puts(Name)
}
9.
To show the use of static function.
10.
To show the working of function returning object.
1.
2.
(i) None of data members are accessible from objects belonging to class AUTHOR.
(ii) Enter(), Show()
(iii) Data members: Voucher_No, Sales_Date, Salary Member function:Sales_Entry(),Sales_Detail(),Enter(),Show(),Register(), Status()
(iv) 66
3.
class TEST
{
int TestCode;
char Description[20];
int NoCandidate,CenterReqd;
void CALCNTR();
public:
void SCHEDULE();
void DISPTEST(); };
void TEST::CALCNTR()
{
CenterReqd=(NoCandidate/100 + 1);
}
void TEST::SCHEDULE ()
{
cout << "Test Code :"; cin >>TestCode;
cout <<" Description :"gets (Description);
cout << "Number :"cin >> NoCandidate;
CALCNTR( );
}
void TEST::DISPTEST( )
{ cout<<"Test Code :"<< Test Code << end1;
cout << " Description :"<< Description << end1;
cout << " Centers :" < CenterReqd << end1;
}
4.
(i) Single inheritance.
(ii) database(char na[12], int value);
{
strcpy(name,na);
d=value;
}
(iii) output
Data number:15
Database Name:SQL
Database Value:10
5.
(i) Multiple Inheritance.
(ii) void Display() of class ITEM.
void Enter() of class ITEM.
void Display() of class SHOP.
void TEnter() of class SUPPLIER.
void TDisplay() of class SUPPLIER.
(iii) void Display() of class SHOP.
void Enter() of class SHOP.
void Display() of class ITEM.
void Enter() of class ITEM.
(iv) SUPPLIER(), ITEM() and SHOP().
6.
(i) Multilevel Inheritance.
(ii) OverallGrade, Remarks[20].
(iii) REvaluate(), RPrint(), Sentry(), Sdisplay().
(iv) Marks[5], Grade[5], SName[20].
7.
#include<iostream.h>
void Print() //Function[I]
{
for(int K=1; K<=60; K++)
cout<<"-"; cout<<end1;
}
void Print(int N) //Function[II]
{
for(K=1; K<=N; K++)
cout<<"*"; cout<<end1;
}
void Print(int A, int B) //Function[III]
{
for(K=1; K<=B; K++)
cout<<A*K; cout<<end1;
}
void Print(char T, int N) //Function[IV]
{
for(K=1;K<=N;K++)
cout<<T; cout<<end1;
}
void main()
{
int U=9, V=4, W=3;
char C='@';
Print(C,V);
Print(U,W);
}
Ans Output
@@@@
91827
In the above example, the function overloading concept is used from function [I] to [IV].
8.
iNTTaNEE
9.
#include<iostream.h>
#include<conio.h>
class test
{
int code;
static int count;
public :
void setccode(void)
{
code = ++count;
}
void showcode(void)
{
cout<<"object number ";
cout<<code<<end1;
}
static void showcount(void)
{
cout<<"count "<<count<<end1;
}
} ;
int test :: count;
void main()
{
test t1, t2;
t1.setcode();
t2.setcode();
test :: showcount();
//accessing static function
test t3;
t3.setcode();
test :: showcount();
t1.showcode();
t2.showcode();
t3.showcode();
getch();
}
Output
count 2
count 3
object number 1
object number 2
onject number 3
10.
Output
Enter the first time in hh mm ss format
12 30 55
Enter the second time in hh mm ss format
8 10 45
First time is
HOURS 12
MINUTES 30
SECONDS 55
Second time is
HOURS 8
MINUTES 10
SECONDS 45
Resultant time is
HOURS 20
MINUTES 41
SECONDS 40
12th Standard CBSE Syllabus & Materials
12th Standard CBSE
CBSE 12th Computer Science Python Revision Tour I - New Previous year Question Papers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Planning Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Business Environment Important Questions And Answers Study Material - QB365 Set A
NEW12th Standard CBSE
CBSE 12th Business Studies Principles of Management Important Questions And Answers Study Material - QB365 Set A
CBSE 12th Standard CBSE Subjects
CBSE Standards