NEW
Font size
WorksheetsC++ Object-Oriented Programming Quiz
Total questions: 55
Worksheet time: 28mins
Which feature of OOP allows the same function name to have different implementations?
Abstraction
Polymorphism
Encapsulation
Inheritance
Which C++ feature helps avoid code duplication?
Inheritance
Virtual functions
Operator overloading
Destructors
Which of these is used to free memory allocated with new?
free()
delete
remove()
clear()
Which of these concepts binds code and data together?
Polymorphism
Encapsulation
Abstraction
Overloading
The process of defining more than one function with the same name but different parameters is called:
Function overriding
Function overloading
Operator overloading
Inheritance
Which of the following supports runtime polymorphism?
Virtual functions
Function overloading
Operator overloading
Inline functions
Virtual functions are declared using:
virtual keyword
dynamic keyword
override keyword
polymorphic keyword
Which type of binding is used in virtual functions?
Early binding
Late binding
Static binding
Compile-time binding
Function overriding requires:
Same name, different parameters
Same name, same parameters, and inheritance
Same name, different return type
None
If a base class pointer points to a derived class object and the function is virtual:
Base version is called
Derived version is called
Random
Error
Which keyword is used in the derived class to ensure overriding?
override (in modern C++)
virtual
polymorph
extends
Which of the following is not a type of inheritance in C++?
Single
Multiple
Multilevel
Parallel
Protected members are accessible in:
Same class only
Derived classes and same class
Outside the class directly
None
Which access mode makes base class members private in derived class?
public
protected
private
default
Constructors of base class are called:
After derived class constructor
Before derived class constructor
Randomly
Not at all
Which keyword is used for inheritance in C++?
extends
:
implements
->
Which inheritance allows a class to be derived from more than one base class?
Single
Multiple
Hierarchical
Multilevel
In multiple inheritance, if two base classes have the same function name, which is used?
First base class
Last base class
Depends on scope resolution operator
Random
Which of these is true about constructors in derived classes?
Base constructor is always called first
Derived constructor is always called first
Order is undefined
No constructor is called
Operator overloading is used to:
Define new operators
Change how existing operators work for objects
Create new keywords
None of the above
Which operator cannot be overloaded?
+
=
::
[]
Unary operator overloading usually takes:
No parameters for member function
One parameter for non-member function
Both a and b
Two parameters always
Which type of polymorphism does operator overloading support?
Compile-time
Run-time
Both
None
Function overloading is resolved at:
Compile-time
Run-time
Link-time
Preprocessing
Which is correct for overloading binary operators as member functions?
They take one argument
They take two arguments
They take no arguments
Only static
A constructor has the same name as:
The class
The file
The first member variable
None
Which of these is not a type of constructor?
Default
Parameterized
Copy
Virtual
Which constructor is called when an object is created without arguments?
Default
Parameterized
Copy
Destructor
A destructor is declared using:
~ClassName()
#ClassName()
delete ClassName()
free ClassName()
Can a constructor be overloaded?
Yes
No
Only default constructor
Only parameterized constructor
The copy constructor is called when:
An object is copied to another
An object is destroyed
A class is declared
A variable is assigned
Which of the following is true about destructors?
They take arguments
They return values
They cannot be overloaded
They can be virtual only in base classes
Which keyword is used to define a class in C++?
struct
class
object
define
Which of the following is not an access specifier in C++?
public
private
protected
friend
Members declared as private are accessible:
Only within the class
From any function
From derived classes only
From main function directly
Objects are instances of:
Functions
Classes
Arrays
Variables
Which of the following can be declared inside a class?
Variables
Functions
Constructors
All of the above
The keyword this in C++ refers to:
Current function name
Current object pointer
Class name
Parent class
What is the default access specifier for members of a class in C++?
public
private
protected
None
What happens if a class has no access specifier?
Members are private
Members are public
Compiler error
They become protected
Which feature allows a function in C++ to have default arguments?
Function overloading
Function overriding
Default parameters
None of the above
What happens if more than one function has the same name but different parameters?
Error occurs
Function overloading
Function overriding
Polymorphism only at runtime
Which is correct about function overloading in C++?
It is done at runtime
It is done at compile time
It requires inheritance
It is same as overriding
Can default arguments be skipped in the middle of a parameter list?
Yes
No
Only if it’s a pointer
Depends on compiler
Which of the following supports compile-time polymorphism?
Virtual functions
Function overloading
Function overriding
Dynamic binding
Which of these is the correct syntax to take input in C++?
cin >> variable;
scanf("%d", &variable);
input variable;
read(variable);
Which operator is used for insertion (output) in C++?
>
<
::
->
What is the default value of a local variable in C++?
0
NULL
Undefined/garbage value
-1
Which of the following is a valid C++ data type?
int
float
bool
All of the above
In C++, which keyword is used to define a constant value?
final
const
define
fixed
Which of the following best describes Object-Oriented Programming?
Programming based on functions only
Programming organized around data and objects
Programming without classes
Programming using only loops
Which of these is not a feature of OOP?
Encapsulation
Abstraction
Inheritance
Assembly language
What is the main difference between OOP and procedural programming?
OOP focuses on objects, procedural focuses on functions
OOP uses only loops, procedural uses only recursion
OOP is slower
Procedural programming has no variables
In OOP, encapsulation means:
Combining data and functions into a single unit
Hiding implementation details
Inheriting properties from another class
Writing all functions in one file
Abstraction in OOP refers to:
Hiding implementation and showing only essential details
Making functions public
Using operators in classes
Writing shorter code
