Object Oriented Programming - Find Output

1:  

The following program fragment
int i=10;
void main ( )

{
int i=20;
{

int i=30.;
cout << i << :: i ;    
}
}

A.

prints 3010

B.

prints 3020

C.

will result in a run time error

D.

none of the above

 
 

Option: A

Explanation :

:: is basically meant to manipulate a global variable, in case a local variable also has the same name.

Click on Discuss to view users comments.

Write your comments here:



2:  

A function abc is defined as
void abc (int x=0, int y=0)
{
cout << x << y;
}

Which of the following function calls is/are illegal? (Assume h, g are declared as integers)   

A.

abc () ;

B.

abc (h) ;

C.

abc (g, h) ;

D.

None of the above

 
 

Option: D

Explanation :

Both the arguments are optional. All the calls are legal.

Click on Discuss to view users comments.

Write your comments here:



3:  

The following c++ code results in
#include "iostream.h"
void main (void)

{
cout <<  (int i=5) << (int j=6);

}    

A.

compilation error

B.

run time error

C.

link time error

D.

none of the above

 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:



4:  

The statements
int a = 5;
cout << "FIRST" << (a <<2) << "SECOND";
outputs 

A.

FIRST52SECOND

B.

FIRST20SECOND

C.

SECOND25FIRST

D.

an error message

 
 

Option: B

Explanation :

The symbol <<  has a context sensitive meaning. The <<  in (a << 2) means shifting a by 2 bits to the left, which is nothing but multiplying it by 4. So, a < <2 will be 5 x 4 = 20 and hence the output will be FIRST20SECOND.

Click on Discuss to view users comments.

Write your comments here:



5:  

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

A.

prints 10 and the address of x

B.

prints the address of p twice

C.

prints the address of x twice

D.

Both (b) & (c)

 
 

Option: D

Explanation :

int &p=x aliases p to x. This means they refer to the same memory location. So, the address of x will be same as that of p.

Click on Discuss to view users comments.

Write your comments here:




Syllabus covered in this section is-

  • O-O Programming Concepts , Class object instantiation
  • Inheritance, polymorphism and overloading
  • C++ Prograinming - Elements of C++, Tokens,
  • Identifters Variables and constants, data, types
  • Operators, Control, statements
  • Functions
  • Parameter passing
  • Class and objects
  •  Constructors and destructors
  •  Overloading,  Inheritance,
  • Templates, Exception handling

This Section covers OOPS Questions Answers .These questions can be used for the preparation of various competitive and academic exams like

  • UGC NET Computer Science
  • Pre PhD Entrance Exam
  • DOEACC Exams
  • Kendriya Vidyalaya Sangathan Entrance Test
  • Undergraduate Computer Science  Course
  • GATE Computer Science
  • Post Graduate Computer Science Exam
  •  PhD Entrance Exam
  • Computer Engineering

Who can benefit

  • Object Oriented Programming Questions Answers can be used by any student who is preparing for PhD entrance exam, pre PhD entrance exam, entrance exam  or any other such exam.
  • Any student who is preparing for DOEACC exams can also use OOPS questions answers for preparation of his exams.
  • OOPS mcq can be useful for the students who are pursuing any undergraduate or post graduate degree in computer science like BE, ME , Btech, Mtech, .BSc, MSc, BCA, MCA, BS, MS  or any other such degree
  • OOPS mcq with answers and explanation can also be useful for the students who are preparing for any competitive exam or recruitment exams like GATE Computer Science, UGC NET Computer Science, Kendriya Vidyalaya Sangathan PGT exam, PSU, IES or any other such exam.
  • OOPS multiple choice questions answers  can also be used by any candidate who wants to gain credits in OOPS in BS Computer science or MS Computer science,
  • You can download OOPS mcq pdf from this site.
  • You can get access to OOPS multiple choice questions answers EBook.

Various Search Terms Used For This Section Are

  • OOPS Quiz Questions With Answers

  • OOPS Exam Questions Answers

  • OOPS Mcq Questions Answers

  • OOPS Mcq Pdf Download

  • C++ Questions Answers

  • C++ Programming Questions Answers