Exam-style question
Try this first
Explain encapsulation and give one reason why the object-oriented paradigm uses it. Your answer should also distinguish encapsulation from instantiation.
Model answer
What a good answer should say
- Encapsulation is the organisation of data and the methods that operate on it within a class, with access controlled using visibility such as public, private or protected.
- It helps keep implementation details controlled and supports the design principle of encapsulating what varies.
- Instantiation is different: it is the creation of an object based on a class using a constructor.
Explanation
Why this works
A complete answer identifies encapsulation as a class-based way of controlling access to attributes and methods, links it to managing variation or implementation details, and does not confuse it with creating an object. Instantiation specifically concerns creating an object from a class.
Common mistake
No common mistake is linked to this question yet.
