Logo educatepk.com
MCQs & Books free for all subjects and educational help  
Subscribe email alerts:
MCQs Online
MCQs on Object Oriented C++ Programming
Books
MCQs on Object Oriented C++ Programming
MCQ related to Object Oriented programming using C++ for general use and also for job preparation of Public Service Commission
Option image

Q No.1 of 10

The following C++ code results in
#include “iostream.h’’
void main (void)
{
      cout << (int  i=5) <<(int j= 6);
}


Option 1

Compilation error


Option 2

Run time error


Option 3

 

Link time error


Option 4

None of the above


Q No.2 of 10

The statements
int a  =5;      
cout << “FIRST’’ << ( a<< 2 ) << “SECOND”;   
outputs


Option 1

FIRST52 SECOND


Option 2

FIRST20 SECOND


Option 3

 SECOND 25 FIRST


Option 4

An error message


Q No.3 of 10

The following program fragment
void main (  )
{
int   x = 10;
int &p = x ;
cout   << &P   << & x;
}


Option 1

Prints 10 and the address of  x


Option 2

Result in a run time error


Option 3

Prints the address of x and address of p twice


Option 4

None of these


Q No.4 of 10

The declaration

int   x ;

int &p=x ;

Is same as the declaration

int     x, *p ;     p =&x;

This remark is

 


Option 1

True


Option 2

False


Option 3

Sometimes true


Option 4

None of the above


Q No.5 of 10

The following program segment

const int     m= 10;

int & n = m;

n= 11;

cout <<  m  <<  n;


Option 1

Result in compile time error


Option 2

Result in run time error


Option 3

Prints   1111


Option 4

Prints   1011


Q No.6 of 10

The following program segment
int   a =10;

int const   &b=a ;

a= 11;

cout<< a<<b;


Option 1

Results in compile time error


Option 2

Result in run time error


Option 3

Prints   1111


Option 4

None of the above


Q No.7 of 10

Consider the following program segment.
static char   X [3 ] = ’’1234”;
cout <<  x ;
A complete C++ program with these two statements


Option 1

Prints 1234


Option 2

Prints 123


Option 3

Prints 1234 followed by some junk


Option 4

Will give a compilation error


Q No.8 of 10

Consider the declarations

const char cc =’h’ ;

char *cp;

const char *const ccpc =&cc;

char *const cpcp;

Which of the following statements

Statements I:     cp =*cpcp;

Statements II:    **cpcp=*cp;

Statements III:    *cp = **cpcp;

are legal?


Option 1

All are legal


Option 2

All are illegal


Option 3

Only statement   I is illegal.


Option 4

Statements I and III are illegal. 


Q No.9 of 10

class A

{ public:

A  (void)

{  cout  <<  “Howzhat”; }

A (void)

{ cout << “whatizit” }

};

class B:A

{ public :

      B (void )

     {  cout << “WYSIWYG";  }

B  (void)

     cout  << “YACC”; }

};

The declaration B x;


Option 1

Prints Howzhat WYSIWYG YACC  Whatizit


Option 2

prints nothing


Option 3

Prints YACC Whatizit Howzhat WYSIWYG


Option 4

None of the above


Q No.10 of 10

class A

{ public:

A  (void)

{  cout  <<  “Howzhat”; }

A (void)

{ cout << “whatizit” }

};

class B:A

{ public :

      B (void )

     {  cout << “WYSIWYG";  }

B  (void)

     cout  << “YACC”; }

};

If the main function has the two statements

B  x;

   cout<<"done";


Option 1

Howzhat WYSIWYG  YACC Whatizit done.


Option 2

Howzhat WYSIWYG done YACC Whatizit.


Option 3

YACC Whatizit Howzhat WYSIWYG done


Option 4

None of the these.



Correct Answers