CC150第14章JAVA总结 to be continued

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


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);
    }
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值