0 votes
in JAVA by (30.8k points)
What does the expression float a = 35 / 0 return?

i) 0

ii) Not a Number

iii) Infinity

iv) Run time exception

1 Answer

0 votes
by (19.8k points)

iii) Infinity

Reason: In Java, whenever we divide any number (double, float, and long except integer) by zero, it results in infinity. According to the IEEE Standard for Floating-Point Arithmetic (IEEE 754), if we divide 1/0 will give positive infinity, -1/0 will give negative infinity, and 0/0 will give NaN. But on dividing an integer by zero, it throws a runtime exception, i.e., java.lang.ArithmeticException.

Related questions