2009年2月4日 星期三

第15題SampleCode

Given:

11. class Mud{
12. //insert code here
13. System.out.println("hi");
14. }
15. }

And the following five fragments:

public static void main(String...a){
public static void main(String.* a){
public static void main(String... a){
public static void main(String[]... a){
public static void main(String...[] a){

How many of the code fragments, inserted independently at line 12, compile?
A. 0
B. 1
C. 2
D. 3
E. 4
F. 5

答案:D

參考:6-2 Java 方法
---------------------------------------
public static void main(String...a){
public static void main(String.* a){ //Syntax error on token "*", Identifier expected
public static void main(String... a){
public static void main(String[]... a){
public static void main(String...[] a){ //Syntax error on token "...", delete this token

2 則留言:

  1. 作者已經移除這則留言。

    回覆刪除
  2. why I cannot run with "public static void main(String[]... a){".

    I am writing code on Eclipese, get error message:
    "Fatal exception occurred. Program will exit."

    回覆刪除