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 11–20 of 28
Topics in C++ Programming
All OOP Concepts 100
Q.11 Easy OOP Concepts
What is the correct syntax for inheriting from multiple base classes in C++?
A class Derived : Base1, Base2 { };
B class Derived extends Base1, Base2 { };
C class Derived : public Base1, public Base2 { };
D class Derived (Base1, Base2) { };
Correct Answer:  C. class Derived : public Base1, public Base2 { };
EXPLANATION

Multiple inheritance in C++ uses the syntax 'class Derived : public Base1, public Base2 { };' with appropriate access specifiers.

Test
Q.12 Easy OOP Concepts
Which of the following best defines abstraction in OOP?
A Hiding implementation details and showing only essential features
B Creating multiple objects from a single class
C Inheriting properties from parent class
D Overriding virtual functions
Correct Answer:  A. Hiding implementation details and showing only essential features
EXPLANATION

Abstraction is the process of hiding complex implementation details and exposing only the necessary interface to users.

Test
Q.13 Easy OOP Concepts
What does the 'this' pointer represent in C++?
A A pointer to the current class definition
B A pointer to the current object instance
C A pointer to the base class
D A pointer to the next object in memory
Correct Answer:  B. A pointer to the current object instance
EXPLANATION

'this' is a constant pointer that points to the current object instance, allowing members to reference themselves.

Test
Q.14 Easy OOP Concepts
In C++, an abstract class is a class that contains at least one _______.
A static member variable
B private constructor
C pure virtual function
D friend function
Correct Answer:  C. pure virtual function
EXPLANATION

An abstract class must contain at least one pure virtual function, making it impossible to instantiate objects of that class directly.

Test
Q.15 Easy OOP Concepts
Which of the following correctly describes a pure virtual function in C++?
A A function that cannot be called
B A function with no implementation in the base class, forcing derived classes to implement it
C A function that deletes itself after execution
D A function that is always static
Correct Answer:  B. A function with no implementation in the base class, forcing derived classes to implement it
EXPLANATION

A pure virtual function is declared with '= 0' and has no implementation in the base class. Derived classes must override it to create a concrete class.

Test
Q.16 Easy OOP Concepts
In C++, what is the default access specifier for members of a class?
A public
B private
C protected
D internal
Correct Answer:  B. private
EXPLANATION

In C++, the default access specifier for class members is private, meaning they are not accessible outside the class by default.

Test
Q.17 Easy OOP Concepts
Which of the following is a key principle of Object-Oriented Programming that bundles data and methods together?
A Encapsulation
B Polymorphism
C Abstraction
D Inheritance
Correct Answer:  A. Encapsulation
EXPLANATION

Encapsulation is the bundling of data (attributes) and methods (functions) into a single unit called a class, hiding internal details from the outside world.

Test
Q.18 Easy OOP Concepts
In C++, what is the correct way to implement an interface-like behavior?
A Using a class with only public data members
B Using a class with only pure virtual functions
C Using a class with only private members
D Using a struct with all public members
Correct Answer:  B. Using a class with only pure virtual functions
EXPLANATION

In C++, an interface-like behavior is achieved using an abstract class containing only pure virtual functions. Derived classes must implement these functions, enforcing a contract.

Test
Q.19 Easy OOP Concepts
Which access specifier allows a derived class to access members of the base class?
A private
B protected
C internal
D friend
Correct Answer:  B. protected
EXPLANATION

The 'protected' access specifier allows derived classes to access members of the base class while keeping them hidden from the outside world.

Test
Q.20 Easy OOP Concepts
In C++, what is the correct syntax for a pure virtual function?
A virtual void func() = 0;
B abstract void func();
C virtual void func() { }
D void func() = 0;
Correct Answer:  A. virtual void func() = 0;
EXPLANATION

A pure virtual function in C++ is declared with the 'virtual' keyword followed by '= 0'. This makes the function purely virtual, requiring derived classes to implement it.

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