java Thread中,run方法和start方法的区别,下面说法错误的是?
A. 通过调用Thread类的start()方法来启动一个线程,这时此线程是处于就绪状态,并没有运行。
B. 他们都可以实现了多线程运行。
C. run方法是thread的一个普通方法调用。
D. 调用start方法后,一旦得到cpu时间片,就开始执行run()方法。
正确答案:B
1.start方法
用 start方法来启动线程,是真正实现了多线程, 通过调用Thread类的start()方法来启动一个线程,这时此线程处于就绪(可运行)状态,并没有运行,一旦得到cpu时间片,就开始执行run()方法。但要注意的是,此时无需等待run()方法执行完毕,即可继续执行下面的代码。所以run()方法并没有实现多线程。
2.run方法
run()方法只是类的一个普通方法而已,如果直接调用Run方法,程序中依然只有主线程这一个线程,其程序执行路径还是只有一条,还是要顺序执行,还是要等待run方法体执行完毕后才可继续执行下面的代码。
如下哪些是 java 中有效的关键字()
A. native
B. NULL
C. false
D. this
正确答案:AD
The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.
While true and false might appear to be keywords, they are technically boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal.
大概意思:const和goto是保留关键字。true和false看起来像关键字,但严格来说,它们是boolean常量;null看起来也像关键字,但严格来说,它是null常量。
综上,true,false,null不是关键字。而是常量。
下面赋值语句中正确的是()
A. double d=5.3e12;
B. float f=11.1;
C. int i=0.0;
D. Double oD=3;
正确答案:A
Java 中整型默认的是int,浮点默认的是double.
B: double类型的11.1 转成 float,是需要强制转换的
C: double类型的0.0 转成 int,也是需要强制转换的
D: int 转为 封装类型Double,是无法编译的
Double oD = 3.0, 会把double类型的3.0自动装箱为Double 就没有问题
下列哪个对访问修饰符作用范围由大到小排列是正确的?
正确答案:public>protected>default>private