Question:
public class Test {
public static void main(String[]
args) {
float a = 10;
System.out.println(a/0);
}
}
Output:
Infinity
For double and float, Arithmetic Exception is NOT thrown!
If "a" was an Integer (either byte, short, int or long), it would have thrown :
Explanation:
For double and float, Arithmetic Exception is NOT thrown!
If "a" was an Integer (either byte, short, int or long), it would have thrown :
Exception in
thread "main" java.lang.ArithmeticException: / by zero
at Test.main(Test.java:9)
Similar Question:
public class Test {
public static void main(String[]
args) {
float a = 10;
float x = a/0;
System.out.println(a/0+" =
"+x);
}
}
Output:
Infinity = Infinity