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 :: java checked exception 
Java :: Java Thread Example by implementing Runnable interface 
Java :: bfs java 
Java :: Java Create a BufferedOutputStream 
Java :: android foreground services set auto cancel not working 
Java :: thread implements runnable 
Java :: how to make a text field required in android studio 
Java :: android studio clock bar change color programmatically 
Java :: fragment view in XML android 
Java :: jaccard index two vectors R 
Java :: Java FileOutputStream to write data to a File 
Java :: alphabet n vowelin java 
Java :: resizing ImageIcon in JButton java 
Java :: add infinite values to variable java 
Java :: exceptions in java 
Java :: rename action bar android 
Java :: springbootservletinitializer maven dependency 
Java :: app not showing in share menu android 
Java :: dependency injection java 
Java :: reader from string java 
Java :: boolean operators in java 
Java :: java swing border 
Java :: android list tostring 
Java :: difference between linkedlist and arraylist 
Java :: width and height of screen java 
Java :: change fab image programatically 
Java :: java null 
Java :: refreshing method() android studio webview 
Java :: get field name java 
Java :: what is java 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =