Multiple Interface in Java
As Java does not support Multiple Inheritance, but you can implement more than one interfaces like.
interface Sports{
void practice();
void match();
}
interface Study{
void exam();
void read();
}
class Student implements Sports,Study{
@Override
public void practice(){
System.out.println("Practice for Game");
}
@Override
public void match(){
System.out.println("Play a Match");
}
@Override
public void exam(){
System.out.println("Appear to Exam");
}
@Override
public void read(){
System.out.println("Read for Exam");
}
}
public class MultiInterfaceDemo{
public static void main(String []a){
Student S= new Student();
S.practice();
S.match();
S.read();
S.exam();
}
}
Output of Program
Practice for Game
Play a Match
Read for Exam
Appear to Exam
In java one class can implement more than one interfaces, class must override all the methods of all interfaces that is being implemented or class must be abstract.