
38. OCR A Level (H446) SLR7 – 1.2 Object-oriented languages part
Authored by James Cole
Computers
11th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does encapsulation mean in object-oriented languages?
The bundling of data with methods that operate on and restrict direct access to it
The process of inheriting properties from another class
A function within a class
A template for creating objects
Answer explanation
Encapsulation in object-oriented languages refers to the bundling of data with methods that operate on and restrict direct access to it.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why is encapsulation used?
To make code execution faster
To increase the size of the code
To hide the values of an internal state of an object
To allow direct access to object attributes
Answer explanation
Encapsulation is used to hide the values of an internal state of an object, ensuring data integrity and preventing direct access to attributes.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can encapsulated attributes of an object be accessed or changed?
Using external functions only
Via the methods provided by that object
Through global variables
Directly, by any part of the program
Answer explanation
The encapsulated attributes of an object can be accessed or changed via the methods provided by that object.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the main benefit of encapsulation?
It makes the program run faster
It allows unrestricted access to data
It helps keep data related to an object safe
It simplifies the code structure
Answer explanation
The main benefit of encapsulation is that it helps keep data related to an object safe.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if another part of the program tries to alter an object's data without using its methods?
The object is deleted
The program crashes immediately
It results in an error
The data is altered successfully
Answer explanation
Trying to alter an object's data without using its methods results in an error because direct access violates encapsulation and can lead to unexpected behavior.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What analogy is used to describe private attributes in the context of encapsulation?
Global variables
Local variables
Public methods
External functions
Answer explanation
Private attributes in encapsulation are analogous to local variables, as they are only accessible within the class they are defined in.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will happen if you try to directly access an object's private attributes?
The access will be granted
The attribute will become public
The program will ignore the request
It will result in an error
Answer explanation
Accessing an object's private attributes directly will result in an error as private attributes are not meant to be accessed outside the class.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?