0% found this document useful (0 votes)
64 views

OOPSMCQGoogleDocs-coding Blocks

1. The document contains 16 multiple choice questions about object-oriented programming concepts in C++ like polymorphism, inheritance, encapsulation, and class definitions. 2. The questions cover topics such as constructors, destructors, virtual functions, friend functions, static member functions, and input/output streams. 3. Correct answers to the questions are not provided, rather the document serves to test knowledge of fundamental OOP concepts in C++.

Uploaded by

Rishabh pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

OOPSMCQGoogleDocs-coding Blocks

1. The document contains 16 multiple choice questions about object-oriented programming concepts in C++ like polymorphism, inheritance, encapsulation, and class definitions. 2. The questions cover topics such as constructors, destructors, virtual functions, friend functions, static member functions, and input/output streams. 3. Correct answers to the questions are not provided, rather the document serves to test knowledge of fundamental OOP concepts in C++.

Uploaded by

Rishabh pandey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

 

 
 

   OOPS MCQ  
 
Q­1 Which of the following in Object Oriented Programming is supported by 
Function overloading and default arguments features of C++?
A) Inheritance 
B) Abstraction 
C) Polymorphism  
D) Abstraction 
 
Q­2 Which of the following is incorrect with respect to constructors in C++? 
A)  A constructor can call member function of its class. 
B)  If the default constructor is defined explicitly then, compiler will not
define the constructor implicitly, it calls the constructor implicitly. 
C)  A constructor cannot dynamically allocate for an object at the time of 
their construction. 
D)  These cannot be static 
 
Q­3 Predict the output?  
#include <iostream> using namespace std;  
class Test { 
int x; Test() { 
x = 5;  

 
}; 
 
int main() { 
 
Test *t = new Test; 
 
cout << t­>x;  
}  
A) 0 
B) 5 
C) Garbage value 
D) Compiler error  
 
Q­4 Which of the following is correct for virtual function in C++ ? (More than 
one) 
a) Must be declared in public section of class. 
b) Virtual function can be static. 
c) Virtual function should be accessed using pointers. 
d) Virtual function is defined in base class. 
 
Q­5 Multiple inheritance leaves room for a derived class to have _______ 
members. 
A) Dynamic 
B) Private 
C) Public 
D) Ambiguous 
 
Q­6 What makes a class abstract? 
A)  The class must not have method definitions.  
B)  The class must have a constructor that takes no arguments. 
C)  The class must have a function definition equal to zero. 
D)  The class which cannot be instantiated as they are mainly for
inheritance. 
 
Q­7 When two or more classes serve as base class for a derived class, the 
situation is known as __________. 
 
A) multiple inheritance  
B) Inheritance 
C) Encapsulation 
D) hierarchical inheritance 
 
Q­8 __________ allows for the separation of object interactions from 
classes and inheritance into distinct layers of abstraction 
A) Dispatching  
B) Loosening 
C) Detaching 
D) Decoupling 
 
Q­9 What is the use of parametric polymorphism?(more than one)
 
A)  A function or a data type can be written generically so that it can 
handle values identically without depending on their type  
B)  A function or a data type can be written generically so that it can 
handle values identically being dependant on their type  
C)  A function or a data type that can accept parameters  
D)  Both a and c 
Q­10 Which of the following is false for friend function? 
A)  Allows access to private or protected data in a class from outside 
the class  
B)  both a and c 
C)  Too many friend functions may hamper data security 
D)  When a function needs to operate on private data in objects from 
two different classes, the function can be declared as a friend in any 
of the classes 
Q­11 The ____________ functions of the base class are also not inherited 
 
A) friend 
B) Pure virtual function  
C) Both a and b 
D) Virtual function 
 
Q­12 ______________ is actually a parameterized constructor which takes 
some parameters in order to create instance of a class. 
 
A) Implicit constructor 
B) Explicit constructor 
C) Virtual constructor 
D) Parameterized constructor 
 
Q­13 Which of the following is false for a destructor? 
A) The destructor has the same name as the class 
B) If the object was created with a new expression, then its destructor is
called when the delete operator is applied to a pointer to the object  
C) Its main purpose is to clean up and to free the resources 
D) none 
Q­14 Which of the following is true about virtual functions in C++. 
A)  Virtual functions are functions that can be overridden in derived 
class with the same signature. 
B)  Virtual functions enable run­time polymorphism in a inheritance 
hierarchy. 
C)  If a function is 'virtual' in the base class, the most­derived class's 
implementation of the function is called according to the actual type of 
the object referred to, regardless of the declared type of the pointer or 
reference. In non­virtual functions, the functions are called according 
to the type of reference or pointer. 
D)  All of the above 
Q­15 Which of the following are true about static member function? 
1) They can access non­static data members 
2) They can call only other static member functions  
3) They can access global functions and data 
4) They can have this pointer 
5) They cannot be declared as const or volatile 
Q­16 Which of the following is the correct class of the object cout?  
A) iostream 
B) Istream 
C) Ostream 
D) ifstream 
 
Q­17 Which of the following problem causes an exception?  
A) Missing semicolon in statement in main(). 
B) A problem in calling function 
C) A syntax error  
D) A run­time error  
 
 
 
 
 
 
 
 
 
 
   
 
 
 
 
 
   
 
 
 
 
 

You might also like