首页 > 其他 > 详细

TestOverWrite

时间:2017-04-01 22:49:38      阅读:226      评论:0      收藏:0      [点我收藏+]

package org.OverWrite;
class Person{
private String name;
private int age;
public void setName(String name){
this.name=name;
}
public void setAge(int age){
this.age=age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public String getInfo(){
return "Name:"+name+"\n"+"age:"+age;
}

}

class Employee extends Person{
private int salary;
public int getSalary(){
return salary;
}
public void setSalary(int salary){
this.salary=salary;
}
public String getInfo(){
return "Name:"+getName()+"\nage:"+getAge()+"\nschool:"+salary;
}
}
public class TestOverWrite {

public static void main(String[] arg[]) {
// TODO 自动生成的方法存根
Employee employee=new Employee();
employee.setName("Mary");
employee.setAge(20);
employee.setSalary(2000);
System.out.println(employee.getInfo());
}

}

TestOverWrite

原文:http://www.cnblogs.com/wlp1115/p/6657749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!