Answers for "how does interface support multiple inheritance in java"

2

Why Interface Support Multiple Inheritance

As we have explained in the inheritance chapter, multiple inheritance is not supported in the case of class because of ambiguity. However, it is supported in case of an interface because there is no ambiguity. It is because its implementation is provided by the implementation class
Posted by: Guest on August-28-2021
1

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();
   }
}
Posted by: Guest on March-24-2022

Code answers related to "how does interface support multiple inheritance in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language