牛客网错题集
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.因为使用了未初始化的变量,所以不能编译通过.
C.以错误的方式访问了静态方法
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();
}
}