
Object Oriented Programming Quiz
Authored by Cecilio Salonoy
Information Technology (IT)
4th Grade
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
40 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is encapsulation in object-oriented programming?
Writing code in a procedural style
Allowing free access to all class properties
Restricting direct access to some of an object's components
Making code longer and more complex
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which access modifier is commonly used to implement encapsulation?
public
protected
global
private
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In PHP, which keyword restricts property access to within the class only?
public
private
external
abstract
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of getter methods in encapsulation?
To delete object properties
To provide controlled read access to private properties
To directly change class variables
To generate random values
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the role of a setter method in a class?
Sets cookies
Assigns permissions to users
Assigns a value to a private property using a public method
Reads data from the database
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a benefit of encapsulation?
Slower performance
No need for class constructors
Better control over data and security
Increased global variables
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the following class, which method is used to access the $name property?
$person->name;
$person->setName();
$person->getName();
$person->__get();
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?