码迷,mamicode.com
首页 > 其他好文 > 详细

TestOverWrite

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

标签:employee   tin   []   todo   str   turn   main   get   oid   

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

标签:employee   tin   []   todo   str   turn   main   get   oid   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!