Menu
Topics Index
...
`

creating Datatypes1599


If you need explanation Read this topic

If you need Answer Take test on this topic

creating Datatypes1599
What will be the output of the following program?
public class ValueIs {
    public static void main(String args[]) {
        int i = 10;
        float f = 10.0f;
        long l = 10;
        double d = 10.0d;
        char c = 'a';
        boolean b = true;
        Object o = new String("Merit Campus");
        System.out.print(String.valueOf(i) + ", ");
        System.out.print(String.valueOf(f) + ", ");
        System.out.print(String.valueOf(l) + ", ");
        System.out.print(String.valueOf(d) + ", ");
        System.out.print(String.valueOf(c) + ", ");
        System.out.print(String.valueOf(b) + ", ");
        System.out.print(String.valueOf(o));
    }
}

A. 10, 10.0f, 10, 10.0d, a, true, Merit Campus
B. 10, 10.0, 10, 10.0, a, true, Merit Campus
C. 10, 10.000, 10, 10.00000, 97, true, Merit Campus
D. 10, 10.0f, 10, 10.0d, 97, true, Merit Campus
E. Some other output
F. Compilation Error or Runtime Error
Topic: Data Conversion Using valueOf In Java

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.. first 10,10.0f as 10.0 , long 10 double 10.0d as 10.0, and then 'a' ,true and finally object string Merit Campus vl be printed..

Posted by Om Prakash Om    2013-07-12 04:41:17


Ans is B...valueOf() method in String class is overloaded and it converts given value into String

Posted by Krishna Sai    2013-07-12 04:41:41


b

Posted by Dhanunjaya Chowdary    2013-07-12 08:38:33


float 10.0f &double 10.0d doesnot print instead compiler reads hem as 10.0 &10.0

Posted by Dhanunjaya Chowdary    2013-07-12 08:39:47


Congratulations Krishna Sai Mulpuri, you are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-07-13 05:28:34


Received rc!! thanks :)

Posted by Krishna Sai    2013-07-23 03:04:07


© meritcampus 2019

All Rights Reserved.

Open In App