日期:2014-05-20 浏览次数:20705 次
abstract class Student { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getNo() { return no; } public void setNo(String no) { this.no = no; } private String no; public abstract void printlnfo(); public Student() { no="20100701020xx"; name="lx"; } public void print() { System.out.println("name:" +this.getName()); System.out.println("no:" +no); } } public class MaleStudent extends Student { private String gender; public MaleStudent(String gender) { super(); this.gender=gender; } @Override public void printlnfo() { System.out.println("name:"+this.getName()); System.out.println("no:+no"); System.out.println("gender:+gender"); } public static void main(String[] args) { MaleStudent m=new MaleStudent("man"); m.printlnfo(); } }