- 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 - 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; }
Answer : B
Explaination
Only 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 2 - Which operator is required to be overloaded as member function only?
Answer : D
Explaination
Overloaded assignment operator does the job similar to copy constructor and is required to be overloaded as member function of the class.
Q 3 - What is the output of the following program?
#include<iostream> using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; }
Answer : C
Explaination
Comma is called as the separator operator and the associativity is from left to right. Therefore ‘k’ is the expressions resultant.
#include<iostream> using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; }
Answer : B
Explaination
As it is also a character is occupies 1 byte of memory.
Q 5 - The copy constructor is executed on
A - Assigned one object to another object at its creation
B - When objects are sent to function using call by value mechanism
Answer : D
Explaination
Options (a), (b) & (c) are applicable.
Q 6 - (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 7 - What is the output of the following program?
#include<iostream> using namespace std; main() { int x = 5; if(x==5) { if(x==5) break; cout<<"Hello"; } cout<<”Hi”; }
Answer : A
Explaination
compile error, keyword break can appear only within loop/switch statement.
#include<iostream> using namespace std; main() { int x = 5; if(x==5) { if(x==5) break; cout<<"Hello"; } cout<<”Hi”; }
Q 8 - Compiler generates ___ file
Answer : B
Explaination
Compilation is the process of translating high level language statements into equivalent machine code, which is object code.
Q 9 - A single line comment in C++ language source code can begin with _____
Answer : D
Explaination
Two immediate forward slashes are used to comment a single line. A single can be commented by beginning with /* and should be terminated with */ , in general used for multi-line comments.
Q 10 - What is the output of the following program?
#include<iostream> #include<string.h> using namespace std; main() { char s[] = "Hello\0Hi"; cout<<strlen(s)<<" "<<sizeof(s); }
Answer : A
Explaination
Length of the string is count of character upto ‘\0’. sizeof – reports the size of the array.
#include<iostream> #include<string.h> using namespace std; main() { char s[] = "Hello\0Hi"; cout<<strlen(s)<<" "<<sizeof(s); }
To Continue Learning Please Login
Login with Google