package com.hanqi.test; public class Humen { private String speak; private String read; private String listen; public String getSpeak() { return speak; } public void setSpeak(String speak) { this.speak = speak; } public String getRead() { return read; } public void setRead(String read) { this.read = read; } public String getListen() { return listen; } public void setListen(String listen) { this.listen = listen; } public void run() { System.out.println("我会跑"); } public void jump() { System.out.println("我会跳"); } }
package com.hanqi.test; public class Men extends Humen { }
package com.hanqi.test; public class Women extends Humen { }
package com.hanqi.test; public class Testmen { public static void main(String[] args) { Humen h=new Men(); Men m=(Men)h; m.run(); Women w=new Women(); w.jump(); } }