Given the content of three files:



Which statement is true?

A. Only the A.java file compiles successfully.
B. Only the B.java file compiles successfully.
C. Only the C.java file compiles successfully.
D. The A.Java and B.java files compile successfully.
E. The B.java and C.java files compile successfully.
F. The A.Java and C.java files compile successfully.

題解

「A.java」檔案可以成功編譯。

「B.java」檔案會編譯失敗,因為private、protected、public等可見度修飾字只能使用在類別或是物件的欄位和方法,並不能用在區域變數。

「C.java」檔案會編譯失敗,因為「package」只能在所有程式敘述的最上方。