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 - What is the output of the following program?
#include<iostream> using namespace std; class abc { void f(); void g(); int x; }; main() { cout<<sizeof(abc)<<endl; }
Answer : B
Explaination
Only the class member variables constitutes as the size of the class or its object.
#include<iostream> using namespace std; class abc { void f(); void g(); int x; }; main() { cout<<sizeof(abc)<<endl; }
Q 2 - By default the members of the structure are
Answer : C
Explaination
If no access specifiers are specified for structure variables/functions, then the default is considered as public.
Q 3 - The following operator can be used to calculate the value of one number raised to another.
Answer : D
Explaination
There is no such operator in C/C++.
Q 4 - Choose the Object oriented programming language from below.
Answer : D
Explaination
Answer : D
Explaination
Scope resolution operator is used to resolve for the global scope of a variable if the local and global variables conflict by name.
Q 6 - i) single file can be opened by several streams simultaneously.
ii) several files simultaneously can be opened by a single stream
Answer : C
Explaination
Q 7 - What is the outpout of the following program?
#include<iostream> using namespace std; main() { enum { india, is = 7, GREAT }; cout<<india<<" "<<GREAT; }
Answer : C
Explaination
0 8, enums gives the sequence starting with 0. If assigned with a value the sequence continues from the assigned value.
#include<iostream> using namespace std; main() { enum { india, is = 7, GREAT }; cout<<india<<" "<<GREAT; }
Q 8 - What is the size of the following union definition?
#include<iostream> using namespace std; main() { union abc { char a, b, c, d, e, f, g, h; int i; }; cout<<sizeof(abc); }
Answer : C
Explaination
union size is biggest element size of it. All the elements of the union share common memory.
#include<iostream> using namespace std; main() { union abc { char a, b, c, d, e, f, g, h; int i; }; cout<<sizeof(abc); }
Q 9 - The default executable generation on UNIX for a C++ program is ___
Answer : C
Explaination
“a.out” is the default name of the executable generated on both the UNIX and Linux operating systems.
Q 10 - What is the output of the following program?
#include<iostream> using namespace std; void main() { char s[] = "C++"; cout<<s<<" "; s++; cout<<s<<" "; }
Answer : D
Explaination
‘s’ refers to a constant address and cannot be incremented.
#include<iostream> using namespace std; void main() { char s[] = "C++"; cout<<s<<" "; s++; cout<<s<<" "; }