What is encapsulation in C++?
Encapsulation involves bundling data and functions that operate on that data within one unit, usually a class.
What is the role of a constructor in a class?
A constructor initializes an object when it is created, often assigning default values to data members.
What is inheritance in OOP?
Inheritance allows a class to derive properties and behaviors from another class.
What is polymorphism in C++?
Polymorphism allows functions or methods to behave differently based on the object calling them.
Which keyword is used to inherit a class?
The ':' (colon) syntax with public, protected, or private access is used for inheritance in C++.
Which of the following is an access specifier in C++?
Access specifiers define the scope of class members; common specifiers include public, private, and protected.
Loading Questions...
Which method is called automatically when an object is destroyed?
A destructor is automatically called to clean up resources when an object goes out of scope.
How is a class object created in C++?
To create a class object, you declare a variable of the class type.
Which feature allows a derived class to redefine a base class function?
Function overriding allows a subclass to provide a specific implementation of a function defined in its superclass.