Methods (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 are methods in Object-Oriented Programming?
What are methods in Object-Oriented Programming?
Functions within a class
Where can public methods be accessed from?
Where can public methods be accessed from?
Outside the class
What is the primary purpose of public methods?
What is the primary purpose of public methods?
Serve as primary interface
How are private methods marked in Python?
How are private methods marked in Python?
Leading underscore
Can private methods be accessed directly from outside the class?
Can private methods be accessed directly from outside the class?
No, they cannot
What key benefit do public methods provide regarding data access?
What key benefit do public methods provide regarding data access?
Encapsulation
What type of tasks do private methods perform?
What type of tasks do private methods perform?
Auxiliary or supportive
What security benefit do private methods provide?
What security benefit do private methods provide?
Keep details hidden
What happens if you access a private method from outside the class?
What happens if you access a private method from outside the class?
Raises an error
How should private methods be named to signal restricted access?
How should private methods be named to signal restricted access?
Single underscore start
Which method is private: deposit() or _log_transaction()?
Which method is private: deposit() or _log_transaction()?
_log_transaction()
What should you use to interact with objects instead of modifying attributes directly?
What should you use to interact with objects instead of modifying attributes directly?
Public methods
