This section presents you various set of Mock Tests related to C++ Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
C++ Mock Test I Answer : B ExplainationIf a member/s appear in the class with following no access specifier, the default is private.
Answer : C ExplainationFew characters have alternative representation and start with ??. Eg. Fro [ equivalent is ??(
Answer : D ExplainationC++ supports all the forms of inheritance.
Answer : A ExplainationAs inline function gets expanded at the line of call like a macro it executes faster.
Answer : D ExplainationA pure virtual function cannot have a definition.
Answer : B ExplainationIt is sufficient to have one pure virtual function in the class to make it as an abstract class.
Q 7 - 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; }
A - 12
B - 4
C - 8
D - Compile error
Answer : B ExplainationOnly 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 8 - What is the output of the following program?
#include<iostream> using namespace std; class abc { public: static int x; int i; abc() { i = ++x; } }; int abc::x; main() { abc m, n, p; cout<<m.x<<" "<<m.i<<endl; }
A - 3 1
B - 3 3
C - 1 1
D - 1 3
Answer : A ExplainationThe static member variable x shares common memory among all the objects created for the class.
#include<iostream> using namespace std; class abc { public: static int x; int i; abc() { i = ++x; } }; int abc::x; main() { abc m, n, p; cout<<m.x<<" "<<m.i<<endl; }Answer : B Explaination
The purpose of the constructor cannot be overridden in the derived class hence constructor cannot be a virtual.
Answer : C ExplainationScope resolution (::) is not permitted to be overloaded.
Answer : D ExplainationOverloaded assignment operator does the job similar to copy constructor and is required to be overloaded as member function of the class.
Answer : C ExplainationAll the rest are valid keywords of C++.
Answer : B Explainationi=i, is assigning member variable to itself.
#include<iostream> using namespace std; class abc { public: int i; abc(int i) { i = i; } }; main() { abc m(5); cout<<m.i; }Answer : C Explaination
If no access specifiers are specified for structure variables/functions, then the default is considered as public.
Answer : B ExplainationIts an object of istream class.
Answer : A ExplainationJust the way we use dot (.) operator to access members of the class, in similar it is used to access the members of the structure too.
Answer : A ExplainationWith 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.
Answer : C Explainationwchar_t is the data type using which we can hold Unicode characters.
Answer : D Explainationmutable is storage specifier introduced in C++ which is not available in C. A class member declared with mutable is modifiable though the object is constant.
Answer : D ExplainationThere is no such operator in C/C++.
Answer : B ExplainationThe parameter int is just to signify that it is the postfix form overloaded. Shouldnt return reference as per its original behavior.
Q 24 - We can have varying number of arguments for the overloaded form of () operator.
A - True
B - False
Answer : B ExplainationBoth the mentioned operators cannot be overloaded.
Answer Sheet Question Number Answer Key 1 B 2 C 3 D 4 A 5 D 6 B 7 B 8 A 9 B 10 C 11 D 12 C 13 B 14 C 15 A 16 C 17 B 18 A 19 A 20 C 21 D 22 D 23 B 24 A 25 Bcpp_questions_answers.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4