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

📚Quizzes
Attributes (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 do attributes represent in OOP?

The state of an object

Which statement about public attributes is correct?

Can be accessed directly from outside

How are public attributes accessed on an object?

Using dot notation

In Python, what indicates a private attribute?

Single or double underscore prefix

What does encapsulation do?

Restricts direct access to data

What is the purpose of getter methods?

Controlled and secure data retrieval

What is the purpose of setter methods?

Enforce data integrity

What data security benefit do private attributes provide?

Prevent unintended modifications

What can setter methods do before modifying attributes?

Validate data

What is a drawback of public attributes?

Can lead to unintended modifications

What error occurs when accessing private attributes directly outside the class?

Attribute not accessible error

When should public attributes be used?

For data without access restrictions

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

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