Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

C++ Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to C++ Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : D

Explaination

C++ supports all the forms of inheritance.

Answer : B

Explaination

Its an object of istream class.

Q 3 - Pick up the valid declaration for overloading ++ in postfix form where T is the class name.

A - T operator++();

B - T operator++(int);

C - T& operator++();

D - T& operator++(int);

Answer : B

Explaination

The parameter int is just to signify that it is the postfix form overloaded. Shouldnt return reference as per its original behavior.

Q 4 - Choose the Object oriented programming language from below.

A - C++

B - Small talk

C - Simula

D - All the above.

Answer : D

Explaination

Q 5 - The programs machine instructions are store in __ memory segment.

A - Data

B - Stack

C - Heap

D - Code

Answer : D

Explaination

Code segments holds the program instructions and fetched by instruction pointer for execution.

Answer : A

Explaination

Q 7 - What is the output of the following program?

#include<iostream>

using namespace std;
main() { 
   int x = 5;

   if(x==5) {	
      if(x==5) break;
      cout<<"Hello";
   } 

   cout<<Hi; 
}

A - Compile error

B - Hi

C - HelloHi

D - Hello

Answer : A

Explaination

compile error, keyword break can appear only within loop/switch statement.

#include<iostream>

using namespace std;
main() { 
   int x = 5;

   if(x==5) {	
      if(x==5) break;
      cout<<"Hello";
   } 

   cout<<Hi; 
}

Q 8 - What is the output of the following program?

#include<iostream>

using namespace std;
main() { 
   int a[] = {1, 2}, *p = a;
   
   cout<<p[1]; 
}

A - 1

B - 2

C - Compile error

D - Runtime error

Answer : B

Explaination

as p holds the base address then we can access array using p just like with a

#include<iostream>

using namespace std;
main() { 
   int a[] = {1, 2}, *p = a;
   
   cout<<p[1]; 
}

Q 9 - The default executable generation on UNIX for a C++ program is ___

A - a.exe

B - a

C - a.out

D - out.a

Answer : C

Explaination

a.out is the default name of the executable generated on both the UNIX and Linux operating systems.

Q 10 - i) Exceptions can be traced and controlled using conditional statements.

ii) For critical exceptions compiler provides the handler

A - Only (i) is true

B - Only (ii) is true

C - Both (i) & (ii) are true

D - Both (i) && (ii) are false

Answer : B

Explaination

Conditional statements are used to take alternate actions depending upon certain condition but not multi branching. C++ too provides some critical exception handlers.

cpp_questions_answers.htm
Advertisements