首页 > 其他 > 详细

牛客网错题集

时间:2018-12-31 16:23:20      阅读:159      评论:0      收藏:0      [点我收藏+]

牛客网错题集

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();
  }
}

参考链接
https://www.nowcoder.com/profile/8667211/wrongset

牛客网错题集

原文:https://www.cnblogs.com/hglibin/p/10202300.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!