以下是使用 Java 语言实现上述需求的代码: ```java class Phone { private String brand; private int price; public Phone(String brand, int price) { this.brand = brand; this.price = price; } public void call1() { System.out.println("手机打电话"); } } class Miphone extends Phone { public Miphone(String brand, int price) { super(brand, price); } @Override public void call1() { System.out.println("小米手机打电话"); } } public class T3 { public static void main(String[] args) { Phone phone = new Phone("华为", 3000); phone.call1(); Miphone miphone = new Miphone("小米", 2500); miphone.call1(); } } ``` 在上述代码中,首先定义了`Phone`类,包含品牌和价格两个私有成员变量,以及有参构造方法和`call1`方法。然后定义了`Miphone`子类继承`Phone`类,并重写了`call1`方法。在测试类`T3`中创建了`Phone`和`Miphone`对象,并分别调用`call1`方法。 [2024-09-19 17:22:13 | AI写代码神器 | 297点数解答]