1/36
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is inheritance in C++?
Reusing and extending existing class definitions
A class that is inherited from is called a:
Base class
A class that inherits from another class is called a:
Derived class
In inheritance, a derived class automatically gets:
Both attributes and methods
Which relationship best describes inheritance?
is‑a
Which is an example of inheritance?
Dog is an animal
Which relationship represents aggregation/composition?
has‑a
If class B is derived from class A, A is called:
Base class
A class derived from another derived class is called:
Multi‑level derived class
A derived class object contains:
Both base class and its own members
Private members of a base class are:
Not accessible in derived classes
Protected members are accessible in:
Derived classes
Which access specifier allows access in derived classes but not outside?
protected
Default inheritance access specifier for a class is:
private
Default inheritance access specifier for a struct is:
public
When a base class is inherited as public:
Access levels remain unchanged
When a base class is inherited as protected:
Public and protected become protected
When a base class is inherited as private:
Public and protected become private
Private members of a base class:
Cannot be accessed anywhere else
The 'has‑a' relationship is best implemented using:
Composition or aggregation
Which is NOT a valid base class access specifier?
static
Which keyword allows changing access of inherited members?
using
A using declaration can:
Change access level of inherited members
Which statement is TRUE about inheritance?
Derived class extends base class functionality
Why should member variables usually be private?
Data hiding and integrity
What is the relationship between a base class and a derived class?
Base class provides attributes and methods
What keyword is used to inherit a class in C++?
class
What is the purpose of constructors in derived classes?
To initialize derived class objects while calling base class constructors
Which member function allows the derived class to access base class members?
Protected member functions
What happens if a derived class does not explicitly call the base class constructor?
The default constructor of the base class is called automatically.
Can a derived class override base class methods?
Yes, if they are declared virtual in the base class.
What is the purpose of the 'virtual' keyword in C++?
To enable dynamic binding of overridden methods.
What happens during the destruction of the derived class object?
The destructors are called in the reverse order of construction.
What is a pure virtual function?
A function with no implementation in the base class, making it abstract.
What is an abstract class?
A class with at least one pure virtual function.
What does 'multiple inheritance' allow in C++?
A derived class to inherit from more than one base class.
What is the potential issue with multiple inheritance?
The diamond problem, which causes ambiguity in method resolution.