帮忙看看一个关于继承的问题,谢谢!
有如下程序:为什么不能调用父类的move方法?而如果采用eat()方法形式就可以得到我想要的字符串,请相信回答,谢谢了!!
class Animal{
String color;
int weight;
Animal(String a,int b){
color=a;weight=b;}
public String getcolor(){return color;}
public String eat(){
String t="hello";
return t;}
public String move(){System.out.println("how are you");}
}
public class cat extends Animal{
String home;
cat(String a,int b,String c){
super(a,b);
home=c;}
public String gethome(){return home;}
public static void main(String args[]){
cat cat1=new cat("red",25,"cat home");
System.out.println("color:"+cat1.getcolor());
System.out.println(cat1.eat());
cat1.move();
}}