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 - A constructor can be virtual.

A - True

B - False

Answer : B

Explaination

The purpose of the constructor cannot be overridden in the derived class hence constructor cannot be a virtual.

Q 2 - Which of the following is not the keyword in C++?

A - volatile

B - friend

C - extends

D - this

Answer : C

Explaination

All the rest are valid keywords of C++.

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 - What is the output of the following program?

#include<iostream>

using namespace std;
main() { 
   int *p = new int; 
   delete p; 
   delete p; 
   cout<<"Done";
}

A - Done

B - Compile error

C - Runtime error

D - None of the above

Answer : C

Explaination

It is invalid to release memory more than once.

#include<iostream>

using namespace std;
main() { 
   int *p = new int; 
   delete p; 
   delete p; 
   cout<<"Done";
}

Q 6 - Which type of data file is analogous to an audio cassette tape?

A - Random access file

B - Sequential access file

C - Binary file

D - Source code file

Answer : B

Explaination

As the access is linear.

Answer : A

Explaination

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

Answer : B

Explaination

Compilation is the process of translating high level language statements into equivalent machine code, which is object code.

Q 9 - Identify the C++ compiler of Linux

A - cpp

B - g++

C - Borland

D - vc++

Answer : B

Explaination

g++ is GNU C++ compiler for linux. Borland and vc++ (Microsoft visual c++) for windows.

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