牛客網錯題集
阿新 • • 發佈:2018-12-31
aps data 查看 ica question term sta targe pub
C.以錯誤的方式訪問了靜態方法
D.能編譯通過,但因變量為null,不能正常運行.
牛客網錯題集
- 閱讀如下代碼。請問,對語句行 test.hello(). 描述正確的有( )?
class Test{
public static void hello() {
System.out.println("hello");
}
}
public class MyApplication {
public static void main(String[] args) {
Test test = null;
test.hello();
}
}
A.能編譯通過,並正確運行.
B.因為使用了未初始化的變量,所以不能編譯通過.
D.能編譯通過,但因變量為null,不能正常運行.
點擊查看結果
選A 反編譯代碼為 import java.io.PrintStream; class Test { public static void hello() { System.out.println("hello"); } } public class MyApplication { public static void main(String[] args) { Test test = null; Test.hello(); } }
參考鏈接
https://www.nowcoder.com/profile/8667211/wrongset
牛客網錯題集