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);
}
}
本文深入探讨了Java中继承与异常处理的核心概念,包括构造器的私有化影响、finally块的执行特性、final关键字的不同用途,以及如何在Map中实现put()和get()方法的计数功能。

被折叠的 条评论
为什么被折叠?



