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平台上,由于涉及到对系统内部底层资源的调用因此在完成类似的功能时速度可能更快、效率可能更高注意只是“可能”,因为未经公开,也有可能不够稳定或者在下个版本的平台中不被支持
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章