Menu
Topics Index
...
`

Objects for class


If you need explanation Read this topic

If you need Answer Take test on this topic

Objects for class
What will be the output of the following program?
public class FireFox {
    public static void main(String s[]) {
        Float fire = new Float(Float.NaN);
        Float fox = new Float(Float.NaN);
        System.out.print((fire == fox) + " ");
        System.out.print(fire.equals(fox) + " ");
        System.out.print(Float.NaN == Float.NaN);
    }
}

A. false false false
B. true true true
C. true false true
D. false true false
E. Some other output
F. 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 D as fire is not equlas to fox (not a number(nan) it is false and next it is true and after it is false

Posted by Naga Sinst    2014-05-15 12:40:26


Ans is D since fire and float is not a number it returns false and  next returns true and next fire not is fox it returns false

Posted by Bharath Yelchuri    2014-05-15 12:46:21


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-05-16 04:25:24


© meritcampus 2019

All Rights Reserved.

Open In App