What is encapsulation in OOP?

Options

  • A. It is a way of combining various member functions into a single unit
  • B. It is a way of combining various data members and member functions into a single unit which can operate on any data
  • C. It is a way of combining various data members into a single unit
  • D. It is a way of combining various data members and member functions that operate on those data members into a single unit

Correct Answer (Detailed Explanation is Below)

D. It is a way of combining various data members and member functions that operate on those data members into a single unit

Detailed Explanation

Explanation:

Encapsulation in Object-Oriented Programming means:

Wrapping data (variables) and the functions (methods) that operate on that data into a single unit (class).

In C++, encapsulation is achieved using a class.

OOps! You are currently offline.