Object-Oriented Programming Quiz

Object-Oriented Programming Quiz

Assessment

Quiz

Information Technology (IT)

Professional Development

Medium

Created by

Cecilio Salonoy

Used 2+ times

FREE Resource

Student preview

quiz-placeholder

40 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is the primary purpose of exceptions in PHP?

To improve performance

To handle errors and exceptional conditions

To create faster loops

To replace variables

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which PHP keyword is used to define a block of code where exceptions may occur?

throw

catch

try

finally

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Which keyword is used to raise an exception in PHP?

raise

throw

error

catch

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

In the given example, what is the name of the custom exception class?

MyException

CustomException

UserException

DivisionException

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What block of code is executed regardless of whether an exception is thrown or not?

try

throw

catch

finally

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Given the function: function divide($a, $b) { if ($b === 0) { throw new Exception("Division by zero."); } return $a / $b; } What happens when divide(4, 0) is called?

Returns 0

Throws an Exception

Prints "Division by zero."

Ignores the error

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

If an exception is thrown but no catch block is defined, what will happen?

The program ignores the exception

The program continues as normal

The program terminates with a fatal error

The program retries the block

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?