📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      Which of the following correctly describes the concept

      of 'encapsulation' in OOP?
      A Creating a new class from an existing class Correct Answer Incorrect Answer
      B Allowing a method to perform differently based on the object calling it Correct Answer Incorrect Answer
      C Bundling data and methods into a single unit, and restricting direct access to internal details Correct Answer Incorrect Answer
      D The process of converting objects into byte streams for efficient storage or transmission of data Correct Answer Incorrect Answer
      E Allowing one class to acquire the properties of another class Correct Answer Incorrect Answer

      Solution

      Encapsulation is the OOP principle of wrapping data and code together inside a class, and controlling access through access modifiers (private, protected, public). Private attributes are accessed only through public getter/setter methods — this is data hiding. Example: A BankAccount class keeps balance private and exposes only deposit() and withdraw() methods, preventing direct manipulation of the balance variable.

      Practice Next

      Relevant for Exams:

      ask-question