QUESTION NO 117
Given:
1. public class Foo {
2. public void main (String [] args) {
3. system.out.printIn(“Hello World.”);
4. }
5. }
What is the result?
A. An exception is thrown.
B. The code does no compile.
C. “Hello World.” Is printed to the terminal.
D. The program exits without printing anything.
网上搜集的scjp题,往往出题内容中就有错误,所以有时不知道出的题在考那方面?就这道题,如果出对的话,那么就应该选B,为什么答案选A,难道又是出题错误.

解决方案 »

  1.   

    为什么选B 我觉得应该选A啊 抛出运行时异常 找不到main方法
      

  2.   

    main方法的定义有误
    应该是 public static void main(String[] args)编译时没问题的
    运行时抛Exception
    所以选A
      

  3.   

    是A啊,main不是static的运行找不到入口了,如何运行?
      

  4.   

    其实偶感觉这题出的不严密
    问的是
    What is the result?如果那段代码不运行,也就不会抛异常,编译也是能通过,
    还有,不运行代码的时候,更别提打印输出什莫了,d显然也是不对所以,偶觉得应该明确是代码被编译后的结果
    还是运行的结果
      

  5.   

    我没有看清楚,main方法少了static ,以为是在考System写成system后程序会怎么样呢!