Welcome to the Quiz on C++ Object-Oriented Programming (OOP). This quiz explores essential concepts and advanced techniques of object-oriented programming in C++. Each question is accompanied by a clear explanation, ensuring you understand both the correct answers and the underlying principles. Covering topics from basic class and object relationships to advanced concepts like inheritance, polymorphism, and encapsulation, this quiz provides a comprehensive overview of C++ OOP. Whether you're starting out or looking to deepen your understanding, this quiz will help you sharpen your skills in applying OOP principles effectively.
Ready to test your knowledge? Let's delve into C++ Object-Oriented Programming together!
Question 1
Which of the following is not a feature of OOP in C++?
Encapsulation
Inheritance
Polymorphism
Compilation
Question 2
Which OOP concept refers to the ability to create a new class from an existing class?
Encapsulation
Abstraction
Inheritance
Polymorphism
Question 3
Which of the following best describes a constructor in C++?
A function that is called when an object is destroyed
A function that is called when an object is accessed
A function that is called when an object is created
A function that is called when an object is inherited
Question 4
What is the default access specifier for members of a class in C++?
Public
Protected
Private
None
Question 5
What is Encapsulation in C++?
The ability to inherit properties from another class
The ability to overload functions
The ability to create abstract classes
The wrapping of data and methods into a single unit
Question 6
Which OOP principle allows a derived class to override a method in the base class?
Encapsulation
Polymorphism
Abstraction
Inheritance
Question 7
Which of the following type of class allows only one object of it to be created?
Virtual class
Abstract class
Singleton class
Friend class
Question 8
If class A is a friend of class B and class B is a friend of class C, which of the following is true?
Class A is a friend of class C
Class B cannot be a friend of any other class
Class C is a friend of class A
None of the above
Question 9
What will be the output of the below code?
#include<iostream.h>
class Point {
int x, y;
public:
Point(int i = 0, int j = 0) { x = i; y = j; }
int getX() { return x; }
int getY() { return y; }
};
int main() {
Point p1;
Point p2 = p1;
cout << "x = " << p2.getX() << " y = " << p2.getY();
return 0;
}
x = garbage value; y = garbage value
x = 0; y = 0
Compiler Error
Runtime Error
Question 10
Which of the following statements is correct?
Base class pointer cannot point to derived class.
Derived class pointer cannot point to base class.
Pointer to derived class cannot be created.
Pointer to base class cannot be created.
There are 25 questions to complete.