/javaDemo6/src/com/imooc/Person.java
package com.imooc; public class Person { public void say() { System.out.println("人类具有说话的能力"); } }
/javaDemo6/src/com/imooc/Chinese.java
package com.imooc; public class Chinese extends Person{ public void say() { System.out.println("中国人说汉语"); } }
/javaDemo6/src/com/imooc/American.java
package com.imooc; public class American extends Person{ public void say() { System.out.println("美国人说英语"); } }
/javaDemo6/src/com/imooc/Test.java
package com.imooc; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub Chinese p1 = new Chinese(); American p2 = new American(); p1.say(); p2.say(); } }
/javaDemo6/src/com/imooc/APerson.java
package com.imooc; public abstract class APerson { public abstract void say(); }
/javaDemo6/src/com/imooc/Chinese.java
package com.imooc; public class Chinese extends APerson{ public void say() { System.out.println("中国人说汉语"); } }
/javaDemo6/src/com/imooc/American.java
package com.imooc; public class American extends APerson{ public void say() { System.out.println("美国人说英语"); } }
/javaDemo6/src/com/imooc/Test.java
package com.imooc; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub APerson p1 = new Chinese(); APerson p2 = new American(); p1.say(); p2.say(); } }