- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
- C++ Advanced
- C++ Files and Streams
- C++ Exception Handling
- C++ Dynamic Memory
- C++ Namespaces
- C++ Templates
- C++ Preprocessor
- C++ Signal Handling
- C++ Multithreading
- C++ Web Programming
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 - Abstract class is __
A - A class must contain all pure virtual functions
B - A class must contain at least one pure virtual function
C - A class may not contain pure virtual function.
D - A class must contain pure virtual function defined outside the class.
Answer : B
Explaination
It is sufficient to have one pure virtual function in the class to make it as an abstract class.
Q 2 - A user defined header file is included by following statement in general.
Answer : A
Explaination
With 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.
Q 3 - Pick up the valid declaration for overloading ++ in postfix form where T is the class name.
Answer : B
Explaination
The parameter int is just to signify that it is the postfix form overloaded. Shouldn’t return reference as per its original behavior.
Q 4 - Class function which is called automatically as soon as the object is created is called as __
Answer : A
Explaination
If not provided the same, default constructor from the compiler is called automatically otherwise the programmer’s provided constructor gets called.
Q 5 - Which feature of the OOPS gives the concept of reusability?
Answer : C
Explaination
The process of designing a new class (derived) from the existing (base) class to acquire the attributes of the existing is called as inheritance. Inheritance gives the concept of reusability for code/software components.
Q 6 - 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 - What is the output of the following program?
#include<iostream> using namespace std; main() { short unsigned int i = 0; cout<<i--; }
Answer : A
Explaination
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--; }
Answer : D
Explaination
The size of ‘int’ depends upon the complier i.e. whether it is a 16 bit or 32 bit.
Q 9 - What is the output of the following program?
#include<iostream> using namespace std; int x = 5; int &f() { return x; } main() { f() = 10; cout<<x; }
Answer : D
Explaination
A function can return reference, hence it can appear on the left hand side of the assignment operator.
#include<iostream> using namespace std; int x = 5; int &f() { return x; } main() { f() = 10; cout<<x; }
Q 10 - What is the built in library function to compare two strings?
Answer : B
Explaination
strcmp() is the built in function from “string.h” to compare two strings. Returns 0 if both are same strings. Returns -1 if first < second string. Returns 1 first > second.
To Continue Learning Please Login
Login with Google