Which fundamental object-oriented programming (OOP) concept bundles data fields and the methods that operate on that data into a single unit while restricting direct external access?

Answer and explanation

Correct answer: D. Encapsulation

  1. Step 1: Encapsulation wraps data attributes and methods inside classes.
  2. Step 2: By using private access modifiers and public getters/setters, it enforces information hiding and prevents unauthorized external manipulation of internal object state.
Answer
Encapsulation.
Why not the others: 'Polymorphism' allows objects of different classes to respond to the same interface; 'Inheritance' allows classes to derive attributes from parent classes; 'Dynamic binding' resolves method calls at runtime.

Practise more Python Programming, Data Structures, Algorithms, Networks and Cybersecurity.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.