Код: Выделить всё
abstract class Test {
private String fatherName ;
public void setFatherName(String fatherName){
System.out.println(this.getClass().getSimpleName());
this.fatherName=fatherName;
}
public String getFatherName(){
return fatherName;
}
}
Код: Выделить всё
public class Person extends Test{
public static void main(String[] args) {
Test person = new Person(); // #2
person.setFatherName("Jimmy");
System.out.println("father name is : " +person.getFatherName());
}
}
Код: Выделить всё
Person
father name is : Jimmy
Подробнее здесь: https://stackoverflow.com/questions/793 ... ract-class