51,408
社区成员
发帖
与我相关
我的任务
分享package csdn;
interface Shoutable {
public abstract void shout();
}
abstract class Person {
public String name = "Person";
public abstract void speak();
}
class Student extends Person implements Shoutable {
public String name = "Student";
@Override
public void shout() {
System.out.println(name);
}
@Override
public void speak() {
System.out.println(this.name + " language");
}
}
class Teacher extends Person implements Shoutable {
public String name = "Teacher";
@Override
public void shout() {
System.out.println(name);
}
@Override
public void speak() {
System.out.println(this.name + " language");
}
}
public class Over {
public void show(Person person) {
person.speak();
}
public static void main(String[] args) {
Over over = new Over();
Student student = new Student();
over.show(student);
}
}