包a中编写一个类Father,具有属性:年龄(私有)、姓名(公有);具有功能:工作(公有)、开车(公有)。在包a中编写一个子类Son,具有属性:年龄(受保护的)、姓名;具有功能
package a;
public class Father {
private int age;
public String name;
private void play(){
System.out.println("兴趣");
}
public void Study(){
System.out.println("学习");
}
}
package b;
import a.Father;
public class Son extends Father{
protected int age;
public String name;
private void play(){
System.out.println("游戏");
}
public void Study(){
System.out.println("韩语");
}
}
import a.Father;
public class test {
public static void main(String[] args) {
Father t=new Father();
Son c=new Son();
//t.play();私有
t.Study();
//c.play();私有
c.Study();
}
}
