TestOverWrite

Posted 大仁哥汪宝

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TestOverWrite相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章