public class TestEdible{
public static void main(String args[]){
Object[] objects = { new Tiger(),new Chicken(),new Apple()
};
for(int i = 0; i < objects.length; i++)
}
}
class Animal{
}
class Chicken extends Animal implements Edible{
public String howToEat(){
return "Fry it";
}
}
class Tiger extends Animal {
}
abstract class Fruit implements Edible{
}
class Apple extends Fruit{
public String howToEat(){
return "Apple:Make apple cider";
}
}
interface Edible{
public abstract String howToEat();
}
public static void main(String args[]){
Object[] objects = { new Tiger(),new Chicken(),new Apple()
};
for(int i = 0; i < objects.length; i++)
***(P377)
if(objects[i] instanceof Edible)
System.out.println(((Edible)objects[i]).howToEat());}
}
class Animal{
}
class Chicken extends Animal implements Edible{
public String howToEat(){
return "Fry it";
}
}
class Tiger extends Animal {
}
abstract class Fruit implements Edible{
}
class Apple extends Fruit{
public String howToEat(){
return "Apple:Make apple cider";
}
}
interface Edible{
public abstract String howToEat();
}