What will be the output of the following Java code? [code] class isinfinite_output { public static void main(String

What will be the output of the following Java code?
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:
Code:
$ javac isinfinite_output.java
$ java isinfinite_output
true
 

Tìm kiếm

Back
Top