Questions – Exam Papers – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Question Typewise Collection-"Short Answer" Questions - Exam Papers (CPP) No. of Q.23
Q.1   Exam - CBSE12D-2017/02D/4

Answer the questions (i) to (iv) based on the following:

class One
{
  int A1;
protected:
  float A2;
public:
  One();
  void Get1(); void Show1();
};
class Two : private One
{
  int B1;
protected:
  float B2;
public:
  Two();
  void Get2();
  void Show();
};
class Three : public Two
{
  int C1;
public:
  Three();
  void Get3();
  void Show();
};
void main()
{
  Three T;     //Statement 1
  __________________;  //Statement 2
}

(i) Which type of Inheritance out of the following is illustrated in the above example?
-Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

(ii) Write the names of all the member functions, which are directly accessible by the object T of class Three as declared in main() function.

(iii) Write Statement 2 to call function Show() of class Two from the object T of class Three.

(iv) What will be the order of execution of the constructors, when the object T of class Three is declared inside main()?



Q.2   Exam - CBSE12D-2017/02A/2

Differentiate between private and public members of a class in context of Object Oriented Programming. Also give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.



Q.3   Exam - CBSE12A-2015/02D/4

Answer the questions (i) to (iv) based on the following:

class Interior
{
  int OrderId;
  char Address[20];
protected:
  float Advance;
public:
  Interior();
  void Book(); void View();
};
class Painting:public Interior
{
  int WallArea,ColorCode;
protected:
  char Type;
public:
  Painting();
  void PBook();
  void PView();
};
class Billing:public Painting
{
  float Charges;
  void Calculate();
public:
  Billing();
  void Bill();
  void BillPrint();
};

(i) Which type of Inheritance out of the following is illustrated in the above example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class Painting.

(iii) Write the names of all the member functions, which are directly accessible from an object of class Billing.

(iv) What will be the order of execution of the constructors, when an object of class Billing is declared?



Q.4   Exam - CBSE12A-2015/02A/2

What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class and a declaration of an object with the help of it.



Q.5   Exam - CBSE12A-2016/02D/4

Answer the questions (i) to (iv) based on the following:

class ITEM
{
  int Id;
  char IName[20];
protected:
  float Qty;
public:
  ITEM();
  void Enter(); void View();
};
class TRADER
{
  int DCode;
protected:
  char Manager[20];
public:
  TRADER();
  void Enter();
  void View();
};
class SALEPOINT : public ITEM,private TRADER
{
  char Name[20],Location[20];
public :
  SALEPOINT();
  void EnterAll();
  void ViewAll();
};

(i) Which type of Inheritance out of the following is illustrated in the above example?

-Single Level Inheritance
-Multi Level Inheritance
-Multiple Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class SALEPOINT.

(iii) Write the names of all the member functions, which are directly accessible by an object of class SALEPOINT.

(iv) What will be the order of execution of the constructors, when an object of class SALEPOINT is declared?



Q.6   Exam - CBSE12A-2016/02B/2

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included:

class BOOK
{
  long Code ;
  char Title[20];
  float Price;
public:
  BOOK() //Member Function 1
  {
    cout<<”Bought”<<endl;
    Code=10;strcpy(Title,”NoTitle”);Price=100;
  }
  BOOK(int C,char T[],float P) //Member Function 2
  {
    Code=C;
    strcpy(Title,T);
    Price=P;
  }
  void Update(float P) //Member Function 3
  {
    Price+=P;
  }
  void Display() //Member Function 4
  {
    cout<<Code<<”:”<<Title<<”:”<<Price<<endl;
  }
  ~BOOK()        //Member Function 5
  {
    cout<<”Book Discarded!”<<end1;
  }
};
void main()                    //Line 1
{                              //Line 2
  BOOK B,C(101,"Truth",350};   //Line 3
  for (int I=0;I<4;I++)        //Line 4
  {                            //Line 5
    B.Update(50);C.Update(20); //Line 6
    B.Display();C.Display();   //Line 7
  }                            //Line 8
}                              //Line 9  

(i) Which specific concept of object oriented programming out of the following is illustrated by member Function 1 and member Function 2 combined together?

  • Data Encapsulation
  • Polymorphism
  • Inheritance
  • Data Hiding

(ii) How many times the message ”Book Discarded!” will be displayed after executing the above C++ code? Out of Line 1 to Line 9, which line is responsible to display the message ”Book Discarded!”




Which of the following statements is/are valid and why.
int x;

(i)  x=1,024;

(ii) x=(1,024);

 




What will be the value of c after evaluating the given expressions on the left side for following two set of statements. Also justify your answer

(i)  int j=5; int c=(5*++j)%6;
(ii) int j=5; int c=(5*j++)%6;



Only 4 out of 10 names written below can be used as variable names or identifiers by a C++ programmer, can you name them.

4PIN
PIN_$
Identifier
PIN_4
P.I.N.
numb_er
Srl.No.
_SIMPLE_INTEREST
FOUR@IDENTIIFERS
FOUR NAMES




Which of the following math function will return the lowest number as output. Also write output of all functions.

(i) ceil(5.1)
(ii) floor(5.9)
(iii) round(5.99)
(iv) abs(-6)



Q.11   Exam - CBSE12A-2018/03C/3

Let us assume Data[20][15] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element Data[10][5], if the element Data[15][10] is stored at the memory location 15000.



Q.12   Exam - CBSE12A-2018/02D/4

Answer the questions (i) to (iv) based on the following:

class Teacher
{
  int TCode;
  protected:
  char Name[20];
  public:
  Teacher();
  void Enter(); void Show();
};
class Course
{
  int ID;
  protected:
  Char Title[30];
  public:
  Course();
  void Initiate();
  void Display();
};
class Schedule: public Course, private Teacher
{
  int DD,MM,YYYY;
  public:
  Schedule();
  void Start();
  void View();
};
void main()
{
  Schedule S;
}

(i) Which type of Inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the members, which are directly accessible by the member
function View() of class Schedule.
(iii) Write the names of all the members, which are directly accessible by the object S
of class Schedule declared in the main() function.
(iv) What will be the order of execution of the constructors, when the object S of class
Schedule is declared inside main() function?

 



Q.13   Exam - CBSE12A-2018/02A/2

Which function(s) out of the following can be considered as overloaded function(s) in the same program? Also, write the reason for not considering the other(s) as overloaded function(s).

void Execute(char A,int B); //Function 1
void Execute(int A,char B); //Function 2
void Execute(int P=10); //Function 3
void Execute(); //Function 4
int Execute(int A); //Function 5
void Execute(int &K); //Function 6



Q.14   Exam - CBSE12A-2018/01B/1

The following C++ code during compilation reports errors as follows:
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
Error: ‘strcat’ not declared
Error: ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

void main()
{
  ofstream FIN("WISH.TXT");
  char TEXT2[]="good day";
  char TEXT1[]="John!";
  strupr(TEXT2);
  strcat(TEXT1, TEXT2);
  FIN<<TEXT1<<endl;
}



Raju is trying to run the following program in his compiler, but he is unable to do the some due to absence of some header files he forgot to include. Please help him.

int main()
{
ifstream ipfile("LIST.TXT",ios::in);
char ch;
while(!ipfile.eof())
{
ipfile.get(ch);
if(isdigit(ch)) cout<<ch<<" ";
} 
ipfile.close(); 
return 0;
}



Mark the name of required C++ header files for each of the following functions
strlen
getline
exit(0)
tolowerfloor

 




Identify the type of token (literal, identifier, keyword, punctuator etc.) in the following
1) Case    2) { }    3) break      4) O17




Write the following program again using the while loop instead of for loop




Initialise a character variable. Now using the ternary operator within the cout chain of printing, print YES if initialised variable is Y and print NO if it is anything else.




Identify errors in the following variable names and suggest the best alternative name(s) for the given variable.

1)   Alt-text
2)  3M_Company
3)  interest#5
4)  P$
5)  (WonderDrug)




In the following representation of fractional constants, some of them may contain errors in representation. Identify them and explain the reasons.

1)   +123.45

2)   34.45-

3)   5.32E-2

4)   7.89E4.5

5)   00.035




Find the valid and invalid identifiers in the following piece of code segment.

int argument=123;
char c#='#';
float amar_is_a_beautiful_boy=3.45;
int taj mahal=1;
int break=0;
string file.ext="myfile.txt";
cout<<argument<<endl;
cout<<c#<<" "<<amar_is_a_beautiful_boy<<" "<<taj mahal<<endl;
cout<<break<<file.ext<<endl;




Write down identifiers and literals in the code given here.

 

int main()
{
  int a=5;
  cout<<"a="<<a<<endl;
  float b=3.5;
  double c=4.56;
  cout<<"b="<<b<<endl;
  cout<<"c="<<c<<endl;
  cout<<"Sum of a+b+c = "<<a+b+c<<endl;
  return 0;
}