- 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.
Answer : C
Explaination
Scope resolution (::) is not permitted to be overloaded.
Q 2 - Choose the respective delete operator usage for the expression ‘ptr=new int[100]’.
Answer : C
Explaination
Q 3 - Runtime polymorphism is done using.
Answer : C
Explaination
Virtual functions gives the ability to override the functionality of base class into the derived class. Hence achieving dynamic/runtime polymorphism.
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 - The programs machine instructions are store in __ memory segment.
Answer : D
Explaination
Code segments holds the program instructions and fetched by instruction pointer for execution.
Q 6 - A C++ program statements can be commented using
Answer : D
Explaination
Both styles of commenting is available in C++.
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--; }
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; }
Answer : B
Explaination
bool is the reserved keyword and cannot be used an identifier name.
Q 10 - Does both the loops in the following programs prints the correct string length?
#include<iostream> using namespace std; main() { int i; char s[] = "hello"; for(i=0; s[i]; ++i); cout<<i<<endl; i=0; while(s[i++]); cout<<i; }
A - Yes, both the loops prints the correct length
B - Only for loop prints the correct length
Answer : B
Explaination
In while loop 'i' gets incremented after checking for '\0', hence giving 1 more than the length.
#include<iostream> using namespace std; main() { int i; char s[] = "hello"; for(i=0; s[i]; ++i); cout<<i<<endl; i=0; while(s[i++]); cout<<i; }