
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Hello World
- C++ Omitting Namespace
- C++ Tokens
- C++ Constants/Literals
- C++ Keywords
- C++ Identifiers
- C++ Data Types
- C++ Numeric Data Types
- C++ Character Data Type
- C++ Boolean Data Type
- C++ Variable Types
- C++ Variable Scope
- C++ Multiple Variables
- C++ Basic Input/Output
- C++ Modifier Types
- C++ Storage Classes
- C++ Numbers
- C++ Enumeration
- C++ Enum Class
- C++ References
- C++ Date & Time
- C++ Operators
- C++ Arithmetic Operators
- C++ Relational Operators
- C++ Logical Operators
- C++ Bitwise Operators
- C++ Assignment Operators
- C++ sizeof Operator
- C++ Conditional Operator
- C++ Comma Operator
- C++ Member Operators
- C++ Casting Operators
- C++ Pointer Operators
- C++ Operators Precedence
- C++ Unary Operators
- C++ Control Statements
- C++ Decision Making
- C++ if Statement
- C++ if else Statement
- C++ Nested if Statements
- C++ switch Statement
- C++ Nested switch Statements
- C++ Loop Types
- C++ while Loop
- C++ for Loop
- C++ do while Loop
- C++ Foreach Loop
- C++ Nested Loops
- C++ break Statement
- C++ continue Statement
- C++ goto Statement
- C++ Strings
- C++ Strings
- C++ Loop Through a String
- C++ String Length
- C++ String Concatenation
- C++ String Comparison
- C++ Functions
- C++ Functions
- C++ Multiple Function Parameters
- C++ Recursive Function
- C++ Return Values
- C++ Function Overloading
- C++ Function Overriding
- C++ Default Arguments
- C++ Arrays
- C++ Arrays
- C++ Multidimensional Arrays
- C++ Pointer to an Array
- C++ Passing Arrays to Functions
- C++ Return Array from Functions
- C++ Structure & Union
- C++ Structures
- C++ Unions
- C++ Pointers
- C++ Pointers
- C++ Dereferencing
- C++ Modify Pointers
- C++ Class and Objects
- C++ Object Oriented
- C++ Classes & Objects
- C++ Class Member Functions
- C++ Class Access Modifiers
- C++ Static Class Members
- C++ Static Data Members
- C++ Static Member Function
- C++ Inline Functions
- C++ this Pointer
- C++ Friend Functions
- C++ Pointer to Classes
- C++ Constructors
- C++ Constructor & Destructor
- C++ Default Constructors
- C++ Parameterized Constructors
- C++ Copy Constructor
- C++ Constructor Overloading
- C++ Constructor with Default Arguments
- C++ Delegating Constructors
- C++ Constructor Initialization List
- C++ Dynamic Initialization Using Constructors
- C++ Inheritance
- C++ Inheritance
- C++ Multiple Inheritance
- C++ Multilevel Inheritance
- C++ Object-oriented
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
- C++ Virtual Function
- C++ Pure Virtual Functions & Abstract Classes
- C++ File Handling
- C++ Files and Streams
- C++ Reading From File
- C++ Advanced
- C++ Exception Handling
- C++ Dynamic Memory
- C++ Namespaces
- C++ Templates
- C++ Preprocessor
- C++ Signal Handling
- C++ Multithreading
- C++ Web Programming
- C++ Socket Programming
- C++ Concurrency
- C++ Advanced Concepts
- C++ Lambda Expression
- C++ unordered_multiset
C++ Mock Test
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 III
Q 1 - Choose the option not applicable for the constructor.
Answer : C
Explaination
A constructor cant be overridden.
Answer : B
Explaination
An array never is passed with call by value mechanism
Q 3 - A C++ program statements can be commented using
Answer : D
Explaination
Both styles of commenting is available in C++.
Q 4 - HAS-A relationship between the classes is shown through.
Answer : B
Explaination
A class containing anther class object as its member is called as container class and exhibits HAS A relationship.
Q 5 - What is a generic class.
Answer : B
Explaination
Defining a templated class is defining a generic class. Hence functionality of the class is generalized for several types, if applicable.
Q 7 - Which type of data file is analogous to an audio cassette tape?
Answer : B
Explaination
As the access is linear.
Q 8 - 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 9 - With respective to streams >> (operator) is called as
Answer : B
Explaination
It extracts the data from stream into variables.
Q 10 - (i) ios is the base class of istream
(ii) All the files are classified into only 2 types. (1) Text Files (2) Binary Files.
Answer : C
Explaination
Q 11 - An exception is __
Answer : A
Explaination
When the program is in execution phase the possible unavoidable error is called as an exception.
Q 12 - i) Exception handling technically provides multi branching.
ii) Exception handling can be mimicked using goto construct.
Answer : A
Explaination
goto just does the unconditional branching.
Q 13 - What is the output of the following program?
#includeusing namespace std; main() { const int a = 5; a++; cout<
Answer : D
Explaination
Compile error - constant variable cannot be modified.
#includeusing namespace std; main() { const int a = 5; a++; cout<
Q 14 - What is the output of the following program?
#includeusing namespace std; main() { char s[] = "hello", t[] = "hello"; if(s==t) cout<<"eqaul strings"; }
Answer : C
Explaination
No output, as we are comparing both base addresses and are not same.
#includeusing namespace std; main() { char s[] = "hello", t[] = "hello"; if(s==t) cout<<"eqaul strings"; }
Q 15 - What is the outpout of the following program?
#includeusing namespace std; main() { enum { india, is = 7, GREAT }; cout<
Answer : C
Explaination
0 8, enums gives the sequence starting with 0. If assigned with a value the sequence continues from the assigned value.
#includeusing namespace std; main() { enum { india, is = 7, GREAT }; cout<
Q 16 - What is the output of the following program?
#includeusing namespace std; main() { short unsigned int i = 0; cout<
Answer : A
Explaination
0, with post decrement operator value of the variable will be considered as the expressions value and later gets decremented
#includeusing namespace std; main() { short unsigned int i = 0; cout<
Q 17 - What is the output of the following program?
#includeusing namespace std; main() { int x = 5; if(x==5) { if(x==5) break; cout<<"Hello"; } cout<
Answer : A
Explaination
compile error, keyword break can appear only within loop/switch statement.
#includeusing namespace std; main() { int x = 5; if(x==5) { if(x==5) break; cout<<"Hello"; } cout<
Q 18 - What is the output of the following program?
#includeusing namespace std; void f() { static int i; ++i; cout<
Answer : D
Explaination
1 2 3, A static local variables retains its value between the function calls and the default value is 0.
#includeusing namespace std; void f() { static int i; ++i; cout<
Q 19 - What is the output of the following program?
#includeusing namespace std; void f() { cout<<"Hello"< B - Error, as the function is not called.
C - Error, as the function is defined without its declaration
Answer : A
Explaination
No output, apart from the option (a) rest of the comments against the options are invalid
#includeusing namespace std; void f() { cout<<"Hello"<
Q 20 - What is the output of the following program?
#includeusing namespace std; int main () { // local variable declaration: int x = 1; switch(x) { case 1 : cout << "Hi!" << endl; break; default : cout << "Hello!" << endl; } }
Answer : B
Explaination
Hi, control reaches default-case after comparing the rest of case constants.
#includeusing namespace std; int main () { // local variable declaration: int x = 1; switch(x) { case 1 : cout << "Hi!" << endl; break; default : cout << "Hello!" << endl; } }
Q 21 - What is the output of the following program?
#includeusing namespace std; void swap(int m, int n) { int x = m; m = n; n = x; } main() { int x = 5, y = 3; swap(x,y); cout<
Answer : B
Explaination
5 3, call by value mechanism cant alter actual arguments.
#includeusing namespace std; void swap(int m, int n) { int x = m; m = n; n = x; } main() { int x = 5, y = 3; swap(x,y); cout<
Q 22 - What will be the output of the following program?
#include#include using namespace std; main() { cout<
Answer : A
Explaination
0, strcmp return 0 if both the strings are equal
#include#include using namespace std; main() { cout<
Q 23 - What is the output of the following program?
#includeusing namespace std; main() { int r, x = 2; float y = 5; r = y%x; cout<
Answer : D
Explaination
Answer Compile Error, It is invalid that either of the operands for the modulus operator (%) is a real number.
#includeusing namespace std; main() { int r, x = 2; float y = 5; r = y%x; cout<
Q 24 - What is the size of the following union definition?
#includeusing namespace std; main() { union abc { char a, b, c, d, e, f, g, h; int i; }; cout<
Answer : C
Explaination
union size is biggest element size of it. All the elements of the union share common memory.
#includeusing namespace std; main() { union abc { char a, b, c, d, e, f, g, h; int i; }; cout<
Answer : D
Explaination
The size of int depends upon the complier i.e. whether it is a 16 bit or 32 bit.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | C |
2 | B |
3 | D |
4 | B |
5 | B |
6 | A |
7 | B |
8 | C |
9 | B |
10 | C |
11 | A |
12 | A |
13 | D |
14 | C |
15 | C |
16 | A |
17 | A |
18 | D |
19 | A |
20 | B |
21 | B |
22 | A |
23 | D |
24 | C |
25 | D |