Menu
Topics Index
...
`

Math utils test


If you need explanation Read this topic

If you need Answer Take test on this topic

Math utils test
What will be the output of the following program?
public class ValuesOfStr {
    public static void main(String... args) {
        String str = "42";
        try {
            str = str.concat(".5");
            double d = Double.parseDouble(str);
            str = Double.toString(d);
            int x = (int) Math.ceil(Double.valueOf(str).doubleValue());
            System.out.println("Output is: " + x);
        } catch (NumberFormatException e) {
            System.out.println("Exception");
        }
    }
}

A. Output is: 42
B. Output is: 42.5
C. Output is: 43
D. Exception
E. Compilation Error or Runtime Error
Topic: Java Collections - Utility Classes 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.

option c is the answer the ceil function converts 42.5 to 43

Posted by Karteek Paruchuri    2013-05-21 12:57:25


option e is answer since main should have string[] args

Posted by Sai Lalitha Renduchintala    2013-05-21 13:03:47


answer is c the function ceil converts rounds 42.5 to 43

Posted by Ramkumar Boggarapu    2013-05-21 13:18:48


Congratulations Karteek Paruchuri. You are today's daily dose winner. Please send us your mobile details and we will recharge tomorrow after considering the new likes.

Posted by Merit Campus    2013-05-21 14:54:53


Thanq merit campus got the recharge

Posted by Karteek Paruchuri    2013-05-22 12:31:58


© meritcampus 2019

All Rights Reserved.

Open In App