/*
动物,
锚,狗
*/
abstract class Animal
{
public abstract void eat();
}
class Cat extends Animal
{
public void eat()
{
System.out.println("chi yu");
}
public void catchMouse()
{
System.out.println("抓老鼠");
}
}
class Dog extends Animal
{
public void eat()
{
System.out.println("chi gutou");
}
public void kanjia()
{
System.out.println("看家");
}
}
class Pig extends Animal
{
public void eat()
{
System.out.println("饲料");
}
public void gongdi()
{
System.out.println("拱地");
}
}
class DuoTaiDemo
{
public static void main(String[] args)
{
Animal c=new Cat();
c.eat();
/*Cat c=new Cat();
function(c1);
function(new Dog());
*/
}
/*
public static void function(Cat c )
{
c.eat();
}
public static void function( Dog d )
{
d.eat();
}
*/
}
仅当显示请求注释处理时才接受类名称是什么意思?为什么不说错误在哪一行呢?? |
|