Menu
Topics Index
...
`

Network


If you need explanation Read this topic

If you need Answer Take test on this topic

Network
public class Network {
    public static void main(String[] args)     {
        float f = 42.0f;
        float[] f1 = new float[2];
        float[] f2 = new float[2];
        float[] f3 = f1;
        long x = 42;
        f1[0] = 42.0f;
    }
}
Which of the following statement(s) is/are true?
1. f1 == f2
2. f1 == f3
3. f2 == f1[1]
4. x == f1[0]
5. f == f1[0]

A. 1, 2 and 3
B. 2, 4 and 5
C. 1, 3 and 5
D. 4 and 5
E. 4 only
F. None of the above
Topic: Learn Arrays And Loops

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.

D

Posted by Raju VarshnEy    2014-09-12 12:39:10


ans e.
ly 5th s true

Posted by Anand Kumar    2014-09-12 12:46:21


2..here f3=f1=42.0 ,0.0n f2=0.0,0.0

x=42..so b is corect

Posted by Wajahat Khan    2014-09-12 13:15:07


ans is B 2 is correct now f3=f1 array so both are referencing same ,and 5 is correct as f and f1[0] values are same,and 4 is same when comapring typecasting will be done implicilty so 2,4,5 are correct

Posted by Pranavi Prakash    2014-09-12 13:16:01


B. f1!=f2 because of garbage value(which may be different), f1=f3 it is obvious from given code, f2==f1[1] we can't compare array of size 2 with single element, and x=f1[0]=f=42.0

Posted by Ankur Verma    2014-09-12 13:19:12


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

Posted by Merit Campus    2014-09-15 04:48:54


© meritcampus 2019

All Rights Reserved.

Open In App