Home Subjects C++ Programming OOP Concepts

C++ Programming
OOP Concepts

Object oriented C++ for GATE and placement

28 Q 1 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–28 of 28
Topics in C++ Programming
All OOP Concepts 100
Q.21 Easy OOP Concepts
Which of the following best describes polymorphism in C++?
A Ability to create multiple objects of the same class
B Ability of objects to take multiple forms through method overriding and overloading
C Ability to access private members of a class
D Ability to inherit from multiple base classes
Correct Answer:  B. Ability of objects to take multiple forms through method overriding and overloading
EXPLANATION

Polymorphism allows objects to take on multiple forms through compile-time (overloading) and runtime (overriding) mechanisms, enabling flexible and extensible code design.

Test
Q.22 Easy OOP Concepts
In C++, which keyword is used to prevent a class from being inherited?
A final
B sealed
C abstract
D virtual
Correct Answer:  A. final
EXPLANATION

The 'final' keyword (introduced in C++11) prevents a class from being used as a base class for further inheritance.

Test
Q.23 Easy OOP Concepts
What happens when you try to access a private member of a class from outside?
A Runtime error
B Compilation error
C The value is returned as zero
D It depends on the compiler
Correct Answer:  B. Compilation error
EXPLANATION

Accessing private members from outside the class results in a compilation error. The compiler enforces access control at compile time.

Test
Q.24 Easy OOP Concepts
What is the purpose of 'this' pointer in C++?
A To point to the parent class
B To point to the current object
C To create a new object
D To delete an object
Correct Answer:  B. To point to the current object
EXPLANATION

The 'this' pointer is an implicit pointer that points to the current object. It's used to access member variables and functions of the current object.

Test
Q.25 Easy OOP Concepts
Which access specifier allows access from derived classes but not from outside?
A public
B private
C protected
D internal
Correct Answer:  C. protected
EXPLANATION

The 'protected' access specifier allows access from within the class and derived classes, but not from outside the class hierarchy.

Test
Q.26 Easy OOP Concepts
What is the purpose of a virtual function in C++?
A To hide a function from derived classes
B To enable runtime polymorphism
C To make a function memory-efficient
D To prevent function overloading
Correct Answer:  B. To enable runtime polymorphism
EXPLANATION

Virtual functions enable runtime polymorphism by allowing derived classes to override base class methods. The correct method is called based on the object type at runtime.

Test
Q.27 Easy OOP Concepts
Which keyword is used to create a derived class in C++?
A extend
B implements
C :
D inherits
Correct Answer:  C. :
EXPLANATION

In C++, the colon (:) operator is used to specify inheritance. Syntax: class Derived : public Base {}

Test
Q.28 Easy OOP Concepts
What is the default access specifier for class members in C++?
A public
B private
C protected
D internal
Correct Answer:  B. private
EXPLANATION

In C++, the default access specifier for class members is 'private'. Only for structs, the default is 'public'.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips