Menu
Question Index
...

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");
        }
    }
}


Output is: 42
Output is: 42.5
Output is: 43
Exception
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Collections - Utility Classes In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App