5. .?????????? ???????? ??????? ???? ???????? ??????? ??????
?????????? ???? ??????:????????? ????????
public class Human {
public void cout() {
System.out.println("I'm a Human!");
}
}
public class Person extends Human {
public void use() {
Human human1=new Human();
Human human2=new Human(/*No Arguments - Default Constructor @ class Human*/) {
/*Variables that extend class Human*/
int unique=10;
/*Methods that extend class Human*/
public void cout() {
super.cout();
System.out.println("But not just a Human...");
cantAccessDirectly(unique);
}
public void cantAccessDirectly(int u) {
System.out.println("I'm a special kind of Human!");
System.out.println("My Unique ID is: "+u);
}
};
System.out.println("");
System.out.println("cout of human1:");
human1.cout();
System.out.println("");
System.out.println("cout of human2:");
human2.cout();
System.out.println("");
}
}