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 : B

Explaination

It is sufficient to have one pure virtual function in the class to make it as an abstract class.

Q 2 - From the below class choose the proper definition of the member function f().

template <class T>

class abc {
   void f();
};

A - template <class T>

    void abc<T>::f() { }

B - template<class T>

    void abc::f() { }

C - template<T>

    void abc<class T>::f() { }

D - template<T>

    void abc<T>::f() { }

Answer : A

Explaination

Q 3 - We can have varying number of arguments for the overloaded form of () operator.

A - True

B - False

Answer : A

Explaination

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.

Q 6 - With respective to streams >> (operator) is called as

A - Insertion operator

B - Extraction operator

C - Right shift operator

D - Left shift operator

Answer : B

Explaination

It extracts the data from stream into variables.

Q 7 - i) Exception handling technically provides multi branching.

ii) Exception handling can be mimicked using ‘goto’ construct.

A - Only (i) is true

B - Only (ii) is true

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

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

Answer : A

Explaination

goto just does the unconditional branching.

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 - Choose the invalid identifier from the below

A - Int

B - bool

C - DOUBLE

D - __0__

Answer : B

Explaination

bool is the reserved keyword and cannot be used an identifier name.

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

#include<iostream>

using namespace std;
main() {
   char s[] = "Fine";
	*s = 'N';
   
   cout<<s<<endl;
}

A - Fine

B - Nine

C - Compile error

D - Runtime error

Answer : B

Explaination

*s=’N’, changes the character at base address to ‘N’.

#include<iostream>

using namespace std;
main() {
   char s[] = "Fine";
	*s = 'N';
   
   cout<<s<<endl;
}
cpp_questions_answers.htm
Advertisements