Menu
Topics Index
...
`

InfiniteValues2294


If you need explanation Read this topic

If you need Answer Take test on this topic

InfiniteValues2294
What will be the output of the following program?
public class Values {
    public static void main(String args[]) {
        Float d = new Float(0.0 / 0.0);
        Float d1 = new Float(1.2 / 0.0);
        System.out.println(d + " is " + d.isInfinite());
        System.out.println(d1 + " is " + d1.isInfinite());
    }
}

A. 0.0 is false
Infinity is true
B. NaN is false
Infinity is true
C. 0.0 is true
Infinity is true
D. NaN is true
Infinity is true
E. Compilation Error or Runtime Error
Topic: Java isInfinite() And isNaN() Methods In Double Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is B since 0.0/0.0 results nan(not a number) and is not infinity so it is false and 1.2/0.0 resullts infinity and true

Posted by Bharath Yelchuri    2014-04-02 05:14:34


ans is e .divide by zero is an arthimetic  exception

Posted by Chintu Raparthi    2014-04-02 09:33:23


Ans is B because 0.0/0.0 is results not a number  and  d is not infinite so it is false and d1 is infinity ansd is true so ans is B

Posted by Naga Sinst    2014-04-02 14:11:03


Congratulations Naga Sinst. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-04-03 04:36:05


© meritcampus 2019

All Rights Reserved.

Open In App