Object-Oriented Programming · Question 1 · Easy

Which OOP concept means bundling data and the methods that operate on it into a single unit, while restricting direct access to the data?

  1. Inheritance
  2. Encapsulation
  3. Polymorphism
  4. Abstraction
Answer and explanation

Answer: B. Encapsulation

Explanation: Encapsulation wraps data and behaviour together in a class and hides the internal state behind methods, for example private fields with public getters and setters.

Next: Method overloading (same method name, different parameter lists in one class)…

Practise object-oriented programming

Try a fresh set of object-oriented programming questions with an explanation after every answer, free and without signing up: Object-Oriented Programming practice. Or sit a full placement mock test.

More object-oriented programming questions

More technical & programming practice

DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge