子类拥有父类非private属性和方法
package com.lanou.obj;
public class test04 {
public static void main(String[] args) {
}
}
class Animal{
int age;
public Animal(){
}
public Animal(int age){
this.age = age;
}
}
class Tiger extends Animal{
String type;
public Tiger() {
super();
// TODO Auto-generated constructor stub
}
//final修饰的方法不能被重写
public Tiger(String type,int age) {
super(age);//调用父类的构造方法
this.type = type;
//子类重写父类的方法,访问修饰不能更严格
// TODO Auto-generated constructor stub
}
}