1.Declaration And Access Control

1General Comments'static' and 'final' are valid modifiers for both 'variable' and 'method' declarations within a class.
'transient' and 'volatile' modifiers are only valid for 'variables'.
'abstract' and 'native' are only valid for 'methods'.
Note: a class can have only have 'final', 'abstract' and 'public' as modifiers.

2.1private, protected and public can be applied to an Inner class.
2.2synchronized  can only be applied to a method or a block.
2.3 final keyword when applied to a class means the class cannot be subclassed, when applied to a method means the method cannot be overridden (it can be overloaded though) and when applied to a variable means that the variable is a constant. 

3.1. Even if the program is executed without any arguments, the 'args' is NOT NULL. In such case it will be initialized to an arry of Strings of zero elements.
3.2. The finally block is always executed, no matter how control leaves the try block. Only if, in try or catch, System.exit() is called then finally will not be executed

4.1 父類中 protected 的成員,子類中可通過繼承訪問,或通過實例父類對象後訪問(不推薦).如果是子類中方法中通過參數引用父類 protected 的成員,這些 protected 的成員是不可見的(子類中)

5.1 如果子類所有構造函數,沒有用super(),就默認使用super();

6 Local variable don't have any accessiblity. They are accessible only from the block they are declared in.

7First, static statements/blocks are called IN THE ORDER they are defined.
  Next, instance initializer statements/blocks are called IN THE ORDER they are defined.
  Finally, the constructor is called.

8.If you explicitly specify the members then you can't give the size. So option 2 is wrong.
The size of the array is never given during the declaration of an array reference. So option 5 is wrong. int i[4] = { 1, 2, 3, 4 } ;
The size of an array is always associated with the array instance, not the array reference.int  i[ ] = new int[2] {1, 2} ;   

9 The native keyword is applicable to methods only.
A native method cannot be abstract but it can throw exception(s).
一般是指未經官方文檔公開的系統api,這類api大都存在於nt平臺上,由於涉及到對系統內部底層資源的調用因此在完成類似的功能時速度可能更快、效率可能更高注意只是“可能”,因爲未經公開,也有可能不夠穩定或者在下個版本的平臺中不被支持
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章