牛客网-错题本

牛客网-错题本

2019-07-16

1. 关于一下application,说法正确的是?

public class TestP{
    static int x=10;
    static {x+=5}
    public static void main(String[] args){
        System.out.println("x="+x);
    }
    static{x/=3};
}

答案:编译通过,执行结果是:x=3

解析:当类加载时,将静态的全部执行,最后执行main方法。

2. 下列赋值语句正确的是?A

a. double d = 5.3e12; //表示 5.3*10^12 ,科学计数法
b. float f= 11.1; //需要强转为 double,小数默认时double类型,float f = 11.1f 这样写是float;
c. int i =0.0; // double 转 int
d. Double d = 3; //自动装箱的目标必须严格对应它拆箱后的类型,Double d = 3.0;对 (自动装箱)

原文地址:https://www.cnblogs.com/luruihua/p/11195032.html