WorksheetsC++ Quiz 1
Total questions: 30
Worksheet time: 10mins
The scope resolution operator (::) is mainly used in C++ to:
Resolve naming conflicts involving inherited members
Access private class members directly
Define preprocessor-level macros
Implement operator overloading
The inheritance model that allows a derived class to obtain features from more than one base class is:
Single
Multiple
Multilevel
Hierarchical
Ambiguity caused by multiple inheritance (such as identical function names in base classes) is typically resolved using:
this pointer
Scope resolution operator (::)
friend functions
templates
An abstract class is correctly defined as one that:
Cannot be inherited further
Contains no executable member functions
Contains at least one pure virtual function
Cannot hold data members
A tree-structured inheritance model, where several classes derive from a single base, is known as:
Single
Hierarchical
Hybrid
Multilevel
When creating an object of a derived class, the first constructor that executes is the:
Derived class constructor
Base class constructor
Destructor
None
Which of the following holds true regarding constructors in inheritance?
Derived class must manually call the base constructor
Base class constructor is invoked automatically
Constructors can be inherited directly
All constructors are virtual
The diamond problem occurs primarily in:
Multilevel inheritance
Hierarchical inheritance
Multiple inheritance
Single inheritance
An inheritance system combining two or more types of inheritance structures is known as:
Hybrid inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Inheritance enhances which programming principles?
Encapsulation only
Reusability only
Both encapsulation and reusability
None of the above
An access specifier that permits derived classes to use base class members but restricts access outside the hierarchy is:
Private
Protected
Public
Default
If no access mode is specified during inheritance, the default mode for classes is:
Public
Private
Protected
Virtual
Ambiguity arising in multiple inheritance can be avoided by using:
Virtual base class
Inline functions
Operator overloading
Static members
Abstract classes are permitted to:
Be instantiated directly
Contain pure virtual functions
Avoid defining any functions
Block inheritance
To transform a derived class from abstract to concrete, it must override the:
Virtual destructor
Pure virtual function(s)
Constructor
Friend function
In inheritance, constructors of derived classes execute:
Before base constructors
After base constructors
In arbitrary order
Only when explicitly called
Destructors in an inheritance chain run in which order?
Base first, then derived
Derived first, then base
Both simultaneously
Destructors cannot be inherited
To ensure correct destruction when working with pointers to base classes, destructors should be declared as:
const
virtual
protected
static
If a derived class declares no constructor, then upon object creation:
Object creation is impossible
Base class constructor still runs automatically
Compilation fails
Destructor executes instead
Without using virtual base classes, which inheritance model most commonly produces ambiguity?
Single
Multiple
Hybrid
Hierarchical
Which of the following correctly defines a pure virtual function?
virtual void show() = 0;
void show() = 0;
pure virtual void show();
abstract void show();
Ambiguity in inheritance typically arises when:
Two base classes define identically named functions
Only single inheritance is used
A function is overloaded
Virtual destructors are present
Which of the following is not a valid inheritance form supported by C++?
Single
Multiple
Multilevel
Sequential
If both base and derived classes define constructors, the constructor that runs first is from:
Derived
Base
Both simultaneously
Compiler-dependent
Inheritance is often referred to as a mechanism for:
Encapsulation
Specialization
Polymorphism
Abstraction
Which of the following members can be inherited and accessed by derived classes?
Constructors
Private data members
Public member functions
Destructors
A student who inherits from both Person and Athlete classes exhibits which type of inheritance?
Single
Multiple
Hierarchical
Multilevel
When two base classes contain parameterized constructors, the derived class must:
Rely on automatic compiler invocation
Invoke both constructors explicitly in its initializer list
Ignore those constructors
Allow the compiler to choose one randomly
Method overriding in inheritance refers to:
Redefining a base class method inside the derived class
Using friend functions across classes
Implementing operator overloading
None of these
If Class C inherits from B, and B inherits from A, this illustrates:
Single
Multiple
Multilevel
Hybrid
