Object Oriented Programming Quiz

Object Oriented Programming Quiz

Assessment

Quiz

•

Information Technology (IT)

•

4th Grade

•

Practice Problem

•

Medium

Created by

Cecilio Salonoy

Used 2+ times

FREE Resource

Student preview

quiz-placeholder

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?