Attributes (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 do attributes represent in OOP?
What do attributes represent in OOP?
The state of an object
Which statement about public attributes is correct?
Which statement about public attributes is correct?
Can be accessed directly from outside
How are public attributes accessed on an object?
How are public attributes accessed on an object?
Using dot notation
In Python, what indicates a private attribute?
In Python, what indicates a private attribute?
Single or double underscore prefix
What does encapsulation do?
What does encapsulation do?
Restricts direct access to data
What is the purpose of getter methods?
What is the purpose of getter methods?
Controlled and secure data retrieval
What is the purpose of setter methods?
What is the purpose of setter methods?
Enforce data integrity
What data security benefit do private attributes provide?
What data security benefit do private attributes provide?
Prevent unintended modifications
What can setter methods do before modifying attributes?
What can setter methods do before modifying attributes?
Validate data
What is a drawback of public attributes?
What is a drawback of public attributes?
Can lead to unintended modifications
What error occurs when accessing private attributes directly outside the class?
What error occurs when accessing private attributes directly outside the class?
Attribute not accessible error
When should public attributes be used?
When should public attributes be used?
For data without access restrictions
