继承extends:子类继承父类中所有的非私有属性和方法
构造函数不会被继承
子类可以有自己的方法
重写(覆盖):
继承关系下,子类中的方法与父类中继承的方法名相同
参数列表相同,返回值类型相同
this:当前对象
this.属性;当前对象的属性
this([参数]);
super:父类对象
super.属性
super([参数]);
package com.zking.test;
/**
* 动物类
* @author d
*
*/
public class Animal {
int id;
String name="动物";
int age;
public void eat() {
System.out.println("吃");
}
public void sleep() {
System.out.println("睡觉");
}
public void run() {
System.out.println("跑得快真好");
}
}