• Courses
  • Tutorials
  • Practice
Switch to Dark Mode

Quiz on C++ OOP

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!

Last Updated : Aug 5, 2024
Discuss
Comments

Question 1

Which of the following is not a feature of OOP in C++?

  • A

    Encapsulation

  • B

    Inheritance

  • C

    Polymorphism

  • D

    Compilation

Question 2

Which OOP concept refers to the ability to create a new class from an existing class?

  • A

    Encapsulation

  • B

    Abstraction

  • C

    Inheritance

  • D

    Polymorphism

Question 3

Which of the following best describes a constructor in C++?

  • A

    A function that is called when an object is destroyed

  • B

    A function that is called when an object is accessed

  • C

    A function that is called when an object is created

  • D

    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++?

  • A

    Public

  • B

    Protected

  • C

    Private

  • D

    None

Question 5

What is Encapsulation in C++?

  • A

    The ability to inherit properties from another class

  • B

    The ability to overload functions

  • C

    The ability to create abstract classes

  • D

    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?

  • A

    Encapsulation

  • B

    Polymorphism

  • C

    Abstraction

  • D

    Inheritance

Question 7

Which of the following type of class allows only one object of it to be created?

  • A

    Virtual class

  • B

    Abstract class

  • C

    Singleton class

  • D

    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?

  • A

    Class A is a friend of class C

  • B

    Class B cannot be a friend of any other class

  • C

    Class C is a friend of class A

  • D

    None of the above

Question 9

What will be the output of the below code?

C++
#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;
}
  • A

    x = garbage value; y = garbage value

  • B

    x = 0; y = 0

  • C

    Compiler Error

  • D

    Runtime Error

Question 10

Which of the following statements is correct?

  • A

    Base class pointer cannot point to derived class.

  • B

    Derived class pointer cannot point to base class.

  • C

    Pointer to derived class cannot be created.

  • D

    Pointer to base class cannot be created.

There are 25 questions to complete.

Take a part in the ongoing discussion