1.In terms of inheritance, what is the effect of keeping a constructor private?
cannot instantiate the class directly.
cannot be inherited.
不能被继承,实例化只能在类内构造静态方法
2.In Java, does the finally block gets executed if we insert a return statement inside thetry block of a try-catch-finally?
Yes, no matter using return, continue or break, the finally block will be executed.
3.What is the difference between final, finally, and finalize?
final:variable:value cannot be changed
method:cannot be overridden
class:cannot be subclassed
finally: be used in try/catch block
finally: method that be executed before running the garbage collector
4. to be continued
5.to be continued
6. 如何在使用MAP是加上对put()和get()的计数功能。
重写MAP的put()和get(),使用静态变量计数
class Mapp<K,V> extends HashMap<K,V>{
static int num;
@Override
public V get(Object k){
num++;
return super.get(k);
}
}