xxxxxxxxxx
interface A
{
public void execute(int num1);
}
interface B
{
public void execute(int num1);
}
class C implements A, B
{
public void execute(int num1)
{
System.out.println("Hello.. From Implementation Class!!");
}
}
public class Main
{
public static void main(String[] args)
{
C obj = new C();
obj.execute(16);
}
}
xxxxxxxxxx
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();
}
}
xxxxxxxxxx
Java does not support multiple inheritance by default, but that would be achieved through Inheritance.
an interface in Java can extend another interface. An interface can inherit the methods and constants defined in another interface, just like a class can inherit from another class.
When an interface extends another interface, it gains all the methods and constants defined in the parent interface, and can also add additional methods and constants of its own. To extend an interface, you use the extends keyword followed by the name of the parent interface: