【简答题】下面的程序用来统计狗和猫叫的次数。为此为狗Dog和猫Cat定义了一个公共父类Counter。程序代码如下class Counterprivate static int count;public static void increment count++;public static int getCount return count;class Dog extends Counterpub
该程序可以实现狗和猫分别叫的总次数。静态成员会被继承,所以子类可以直接使用父类的静态方法和变量。
因此,程序没有问题,不需要改正。
原文地址: https://www.cveoy.top/t/topic/g0wS 著作权归作者所有。请勿转载和采集!