这个算实现多态了吗?
package text; public class Vehicle { public String name; public String tWay; public int tNum; public void show() { System.out.println("父类方法不会执行!"); } } package text; public class Steamship extends Vehicle { public Streamship(){ name = "轮船"; tNum = 400; tWay = "海上"; } public void show() { System.out.println(name + "在" + tWay + ",可以运输" + tNum + "人。"); } } package text; public class InitialVehicle { public static void main(String[] args) { Vehicle s=new Steamship(); s.show(); } }
另外两个飞机和公车的子类是一样的就不贴上来了。