Search
 
SCRIPT & CODE EXAMPLE
 

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();
   }
}
Comment

multiple inheritance in java

Multiple inheritance is achieved and
implemented using interfaces
Comment

PREVIOUS NEXT
Code Example
Java :: path in spring form 
Java :: recyclerview adapter multiple view types 
Java :: Java Singleton Class Syntax 
Java :: Implementing the LinkedList Class in java list 
Java :: switch in java 
Java :: Java Enum compareTo() 
Java :: java sort reverse lambda 
Java :: what is encapsulation in java 
Java :: array in java 
Java :: enhanced for loop java 
Java :: Java Iterating through LinkedList 
Java :: android activity transition 
Java :: method overriding in java 
Java :: Java Abstract Class and Method 
Java :: inorder traversal 
Java :: Send HTTP Get Request with Parameters. 
Java :: deep content 
Java :: java truncate bigdecimal 
Java :: java exception handling 
Java :: Java program to swap two numbers using bitwise xor operator 
Java :: Java Create a WeakHashMap 
Java :: view binding 
Java :: sum of no 
Java :: What is the use of @Listener annotation in TestNG? 
Java :: java convert 2d array to 1d stream 
Java :: random numeros negativos java 
Java :: Java Boolean Literals 
Java :: java hashmap get nonexistent key 
Java :: code for working clock in java eclipse 
Java :: how to enforce xml dtd validation in java 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =