VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/quiz-on-cpp-oop/

⇱ Quiz about Object Oriented Programming in C++


Last Updated :
Discuss
Comments

Question 1

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 2

Which OOP concept in C# is used to restrict direct access to data and allow it only through methods?

  • Encapsulation

  • Abstraction

  • Data hiding

  • Data binding

Question 3

What is the main benefit of encapsulation in C++?

  • Faster execution

  •  Better UI design

  • Data security and abstraction

  • Simplified syntax

Question 4

Which of the following best describes abstraction?


  • Hiding implementation details and showing only relevant information to the users.

  • Binding both data members and member functions into a single unit.

  • Accessing data members and member functions of one class by other

  • All of the above

Question 5

Which access specifier provides the highest level of protection?

  • private

  •  protected

  • public

  • None of the above

Question 6

Which of the following correctly defines function overloading and function overriding in C++?

  • Overloading occurs when two or more methods in the same class have the same name but different parameters overriding occurs when a derived class has a definition for one of the member functions of the base class.

  • Overloading occurs in the same class, overriding occurs between a base class and a derived class

  • Overloading requires the use of the 'virtual' keyword, overriding does not.

  • Overloading and overriding are the same in C++.

Question 7

What will be the output of the following program?

  • Base

  • Derived

  • Compilation error

  • Runtime error

Question 8

  • Compiler Error
  • 1 2 3
  • 1 1 1
  • 3 3 3
  • 0 0 0

Question 9

Which access specifier is commonly used to hide data in abstraction?

  • Public

  • Private

  • Protected

  • Any of these

Question 10

Which of the following operators should be preferred to overload as a global function rather than a member method?
  • Postfix ++
  • Comparison Operator
  • Insertion Operator <<
  • Prefix++

There are 11 questions to complete.

Take a part in the ongoing discussion