Encapsulation (OOP) (OCR A-Level Computer Science): Quizzes

📚Quizzes
Encapsulation (OOP)
Sign up to keep practising.Create a free account to play more quizzes and track your progress.

Practise the questions

12 questions from this quiz

Show

What is encapsulation in OOP?

Restricts direct access to object data

How are private attributes signalled in Python?

Leading underscore _ or __

What do getter methods provide?

Read-only access to private data

What can setter methods include to ensure data validity?

Validation logic

How does encapsulation enhance data security?

Prevents unauthorised modifications

What benefit comes from grouping related data and methods in a class?

Modularity

In the BankAccount example, what type of attribute is __balance?

Private

What are getter methods also called?

Accessors

What does encapsulation allow developers to control?

How and when data is changed

What happens when modifying private attributes directly from outside a class?

Leads to an error

Why is encapsulated code easier to maintain?

Changes are isolated within class

What is compromised if setters lack validation?

Data integrity

Join 100,000+ A-Level students studying Quizzes with us.

Select your subjects, and get access to A+ resources today.