Encapsulation (OOP) (OCR A-Level Computer Science): Quizzes
📚Quizzes
Practise the questions
12 questions from this quiz
ShowHide
Practise the questions
12 questions from this quiz
What is encapsulation in OOP?
What is encapsulation in OOP?
Restricts direct access to object data
How are private attributes signalled in Python?
How are private attributes signalled in Python?
Leading underscore _ or __
What do getter methods provide?
What do getter methods provide?
Read-only access to private data
What can setter methods include to ensure data validity?
What can setter methods include to ensure data validity?
Validation logic
How does encapsulation enhance data security?
How does encapsulation enhance data security?
Prevents unauthorised modifications
What benefit comes from grouping related data and methods in a class?
What benefit comes from grouping related data and methods in a class?
Modularity
In the BankAccount example, what type of attribute is __balance?
In the BankAccount example, what type of attribute is __balance?
Private
What are getter methods also called?
What are getter methods also called?
Accessors
What does encapsulation allow developers to control?
What does encapsulation allow developers to control?
How and when data is changed
What happens when modifying private attributes directly from outside a class?
What happens when modifying private attributes directly from outside a class?
Leads to an error
Why is encapsulated code easier to maintain?
Why is encapsulated code easier to maintain?
Changes are isolated within class
What is compromised if setters lack validation?
What is compromised if setters lack validation?
Data integrity
