Menu
Topics Index
...
`

Comparison 2291


If you need explanation Read this topic

If you need Answer Take test on this topic

Comparison 2291
What will be the output of the following program?
public class Comparison {
    public static void main(String args[]) {
        float f1 = 30.5f;
        Float f2 = new Float(36.5);
        int l = Float.compare(f2, f1);
        System.out.print(l);
    }
}

A. 1
B. -1
C. 6
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java Double Class And Java Float 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  a bcz
first f1=30.5
then compare(36.5,30.5) is done as 36.5>30.5 compare returns positive value 1

Posted by Pooja Singh    2014-06-11 13:09:54


ans is c...f2 is grtr than f1 so it wl return 6..it wl return dfrnc

Posted by Uday Kumar    2014-06-11 13:10:08


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

Posted by Merit Campus    2014-06-12 03:56:57


© meritcampus 2019

All Rights Reserved.

Open In App