package a; public class Father { public String name; private int age; public Father(String name) { this.name=name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Father(int age) { super(); this.age = age; } public void gongzuo() { System.out.println("父亲的工作"); } public void kaiche() { System.out.println("父亲开车"); } }
package a; public class Son { protected int age; String name; public Son(int age) { super(); this.age = age; } public Son(String name) { this.name=name; } private void wan() { System.out.println("儿子玩"); } public void xvexi() { System.out.println("儿子的学习"); }
package b; import a.Father; import a.Son; public class Test { public static void main(String[] args) { Father fuqin=new Father(""); Son erzi=new Son(""); fuqin.gongzuo(); fuqin.kaiche(); // erzi.wan(); erzi.xvexi(); } }