屬性初始化值

 
16. Given the following code: public class Test{ static long a[] = new long[10]; public static void main ( String arg[] ) { System.out.println ( a[6] ); } } Which statement is true? 下面關於long數組的代碼運行結果是什麼?
 
備選答案: A : Output is null.
B : Output is 0.
C : When compile, some error will occur.
D : When running, some error will occur.
你的回答: D
回答結果:
答案: B
答案詳解: 類一級的屬性會被自動初始化。 主類型中數字默認爲0,boolen默認爲false 對象則默認爲null.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章