Skip to content
Sharp

Exceptions · interview question

What type of exception does the following code throw if the divisor is zero?

Multiple choiceEasychapter-6-curatedpremiumexceptionsexceptions-basics
java
int result = 10 / divisor;
Choose one answer
Answer and explanation

Correct answer

B. ArithmeticException

Why

Dividing by zero in Java results in an ArithmeticException, which is a runtime exception indicating an illegal operation has occurred.

Test yourself on Exceptions

A free test with instant, explained results. No account needed.

Start free test
All Exceptions questions →