class Demo4_Override {
public static void main(String[] args) {
}
}
class Person {
public void print() {
System.out.println("Person");
}
}
class Student extends Person {
public void print() {
System.out.println("Student");
}
}
class Father {
public Person method() {
return new Person();
}
}
class Son extends Father {
public Student method() {
return new Student();
}
}
上边是代码,father里面的方法返回值是person类型,下边son里方法返回值是student类型的。那么我想问,father里的返回值类型能不能设置成student的?son里的返回值类型能不能设置成person的?求大神帮助解答~
|
|