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.
Q 1 - A trigraph character begins with
A - #
B - ##
C - ?
D - ??
Few characters have alternative representation and start with ??. Eg. Fro [ equivalent is ??(
Q 2 - By default the members of the structure are
A - private
B - protected
C - public
D - Access specifiers not applicable for structures.
If no access specifiers are specified for structure variables/functions, then the default is considered as public.
Q 3 - Runtime polymorphism is done using.
A - Function overloading
B - Virtual classes
C - Virtual functions
D - Friend function
Virtual functions gives the ability to override the functionality of base class into the derived class. Hence achieving dynamic/runtime polymorphism.
Q 4 - How can we make an class act as an interface in C++?
A - By only providing all the functions as virtual functions in the class.
B - Defining the class following with the keyword virtual
C - Defining the class following with the keyword interface
D - Defining the class following with the keyword abstract
There are no keywords in C++ such as abstract and interface.
Q 5 - What is the full form of RTTI.
A - Runtime type identification
B - Runtime template identification
C - Robust Template Type Inheritance
D - None of the above.
 
Q 6 - (i) ‘ios’ is the base class of  ‘istream’
(ii) All the files are classified into only 2 types. (1) Text Files (2) Binary Files.
A - Only (i) is true
B - Only (ii) is true
C - Both (i) & (ii) are true
D - Both (i) & (ii) are false
 
Q 7 - What is the output of the following program?
#include<iostream>

using namespace std;
main() {
   short unsigned int i = 0; 
   
   cout<<i--;
}
A - 0
B - Compile error
C - 65535
D - 32767
0, with post decrement operator value of the variable will be considered as the expression’s value and later gets decremented
#include<iostream>

using namespace std;
main() {
   short unsigned int i = 0; 
   
   cout<<i--;
}
Q 8 - What is the output of the following program?
#include<iostream>

using namespace std;
main() {	
   union abc {
		int x;
		char ch;
	} var;
	
   var.ch = 'A';
   cout<<var.x;
}
A - A
B - Garbage value
C - 65
D - 97
65, as the union variables share common memory for all its elements, x gets ‘A’ whose ASCII value is 65 and is printed.
#include<iostream>

using namespace std;
main() {	
   union abc {
		int x;
		char ch;
	} var;
	
   var.ch = 'A';
   cout<<var.x;
}
Q 9 - An inline function can execute faster than a normal function.
A - True
B - False
As the code of inline function gets expanded at the line of call, therefore it gets executed faster with no overhead of context switch
Q 10 - What is the output of the following program?
#include<iostream>

using namespace std;
main() {	
   int a[] = {10, 20, 30};
   
	cout<<*a+1;
}
A - 10
B - 20
C - 11
D - 21
*a refers to 10 and adding a 1 to it gives 11.
#include<iostream>

using namespace std;
main() {	
   int a[] = {10, 20, 30};
   
	cout<<*a+1;
}

    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page