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

Q 1 - The default access specifer for the class members is

A - public

B - private

C - protected

D - None of the above.

Answer : B

Explaination

If a member/s appear in the class with following no access specifier, the default is private.

Q 2 - A user defined header file is included by following statement in general.

A - #include file.h

B - #include <file.h>

C - #include <file>

D - #include file.h

Answer : A

Explaination

With the syntax as in (a) the compiler first looks for the file in the present working directory and then in the default include path if not found.

Q 3 - In the following program f() is overloaded.

void f(int x) {

}

void f(signed x) {

}

main() {

}

A - True

B - False

Answer : B

Explaination

No, as both the functions signature is same.

Answer : D

Explaination

Q 6 - i) single file can be opened by several streams simultaneously.

ii) several files simultaneously can be opened by a single stream

A - (i) and (ii) are true

B - (i) and (ii) are false

C - Only (i) is true

D - Only (ii) is true

Answer : C

Explaination

Answer : A

Explaination

When the program is in execution phase the possible unavoidable error is called as an exception.

Q 8 - What is the size of int?

A - 2

B - 4

C - 8

D - Compiler dependent

Answer : D

Explaination

The size of int depends upon the complier i.e. whether it is a 16 bit or 32 bit.

Q 9 - A single line comment in C++ language source code can begin with _____

A - ;

B - :

C - /*

D - //

Answer : D

Explaination

Two immediate forward slashes are used to comment a single line. A single can be commented by beginning with /* and should be terminated with */ , in general used for multi-line comments.

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