java吧 关注:1,273,574贴子:12,785,836
  • 1回复贴,共1

310-055-Q&A-Troytec 第200题 为什么是B运行时错误?

只看楼主收藏回复

Question 200
Given the command line java Pass2 and:
15. public class Pass2 {
16. public void main(String [] args) {
17.int x=6;
18. Pass2 p = new Pass2();
19. p.doStuff(x);
20. System.out.print(” main x = “+ x);
21. }
22.
23. void doStuff(int x) {
24. System.out.print(” doStuffx = “+ x++);
25. }
26. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuffx = 6 main x = 6
D. doStuffx = 6 main x = 7
E. doStuffx = 7 main x = 6
F. doStuffx = 7 main x = 7
Answer: B


IP属地:上海1楼2007-08-06 09:33回复
    不好意思,我知道为什么了。 
    main函数漏了static 
    运行的时候找不到需要的那个main函数


    IP属地:上海2楼2007-08-06 09:52
    回复