-
What will be the output of these statement?
class output {
public static void main(String args[])
{
double p, q, r;
p = 3.0/0;
q = 0/4.0;
r = 0/0.0;
System.out.println(p);
System.out.println(q);
System.out.println(r);
}
}
-
- 0.0
- Infinity
- NaN
- all of the mentioned
- None of these
Correct Option: D
For floating point literals, we have constant value to represent (10/0.0) infinity either positive or negative and also have NaN (not a number for undefined like 0/0.0), but for the integral type, we don’t have any constant that’s why we get an arithmetic exception.