Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

multiple inheritance using interface in java

interface AnimalEat {
   void eat();
}
interface AnimalTravel {
   void travel();
}
class Animal implements AnimalEat, AnimalTravel {
   public void eat() {
      System.out.println("Animal is eating");
   }
   public void travel() {
      System.out.println("Animal is travelling");
   }
}
public class Demo {
   public static void main(String args[]) {
      Animal a = new Animal();
      a.eat();
      a.travel();
   }
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #multiple #inheritance #interface #java
ADD COMMENT
Topic
Name
2+1 =