- 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 - One of the following is true for an inline function.
A - It executes faster as it is treated as a macro internally
B - It executes faster because it priority is more than normal function
C - It doesn’t executes faster compared to a normal function
Answer : A
Explaination
As inline function gets expanded at the line of call like a macro it executes faster.
Q 2 - From the below class choose the proper definition of the member function f().
template <class T> class abc { void f(); };
A - template <class T> void abc<T>::f() { }
B - template<class T> void abc::f() { }
Answer : A
Explaination
Q 3 - In the following program f() is overloaded.
void f(int x) { } int f(signed x) { return 1; } main() { }
Answer : B
Explaination
No, as both the functions arguments is same and compiler ignores return type to consider overloading though different in return type.
Q 4 - Designer of C++ programming language.
Answer : D
Explaination
Q 5 - What is the output of the following program?
#include<iostream> using namespace std; main() { int *p = new int; delete p; delete p; cout<<"Done"; }
Answer : C
Explaination
It is invalid to release memory more than once.
#include<iostream> using namespace std; main() { int *p = new int; delete p; delete p; cout<<"Done"; }
Answer : B
Explaination
An array never is passed with call by value mechanism
Q 7 - What is the output of the following program?
#include <iostream> using 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.
#include <iostream> using namespace std; int main () { // local variable declaration: int x = 1; switch(x) { case 1 : cout << "Hi!" << endl; break; default : cout << "Hello!" << endl; } }
Q 8 - What is the output of the following program?
#include<iostream> using 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<<x<<" "<<y; }
Answer : B
Explaination
5 3, call by value mechanism can’t alter actual arguments.
#include<iostream> using 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<<x<<" "<<y; }
Q 9 - Following is the invalid inclusion of a file to the current program. Identify it
Answer : C
Explaination
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Q 10 - i) Exceptions can be traced and controlled using conditional statements.
ii) For critical exceptions compiler provides the handler
Answer : B
Explaination
Conditional statements are used to take alternate actions depending upon certain condition but not multi branching. C++ too provides some critical exception handlers.
To Continue Learning Please Login
Login with Google