标签:
1 public class Student { 2 public String name; 3 public int age; 4 5 public void study(){ 6 System.out.println("学生学习"); 7 } 8 }
1 public class UnStudent extends Student{ 2 public void study(){ 3 System.out.println("大学生的学习方法"); 4 } 5 public void playGame(){ 6 System.out.println("大学生玩dota"); 7 } 8 }
1 public class Test { 2 public static void main(String[] args) { 3 //自动转型 4 UnStudent us = new UnStudent(); 5 Student us1 = new UnStudent(); 6 Student us2 = new Student(); 7 8 us.study(); 9 us1.study(); 10 us2.study(); 11 12 us.playGame(); 13 us1.playGame(); 14 us2.playGame(); 15 } 16 }
1 public interface Teacher { 2 public static final String name = "aa"; 3 public static final String job = "aa"; 4 public static final int age = 20; 5 6 //抽象方法 7 public abstract void play1(); 8 public abstract void play2(); 9 public abstract void play3(); 10 public abstract void play4(); 11 public abstract void play5(); 12 }
1 public abstract class UnTeacher implements Teacher{ 2 3 }
标签:
原文地址:http://www.cnblogs.com/xiaofu007/p/5245203.html