【笔试题】Java Data Types

Java 知识测试 Java Data Types
Question 1
Predict the output of the following program.

class Test {
    public static void main(String[] args) {
        Double object = new Double("2.4");
        int a = object.intValue(); // 2
        byte b = object.byteValue(); // 2
        float c = object.floatValue(); // 2.4
        double d = object.doubleValue(); // 2.4
        System.out.println(a + b + c + d);
    }
}

A. 8
B. 8.8
C. 8.800000095367432

参考答案

C

猜你喜欢

转载自www.cnblogs.com/hglibin/p/11294705.html