
Object-Oriented Programming Quiz
Authored by Cecilio Salonoy
Information Technology (IT)
Professional Development
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
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
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?