Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Java code?
class isinfinite_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isInfinite();
System.out.print(x);
}
}

What will be the output of the following Java code?
class isinfinite_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isInfinite();
System.out.print(x);
}
}
a) 0
b) 1
c) true
d) false

Answer: c
Explanation: isInfinite() method returns true is the value being tested is infinitely large or small in magnitude. 1/0. is infinitely large in magnitude hence true is stored in x.
Output:
true

Join The Discussion