Multiple inheritance:
- A class can extends only one class in java.
- An interface can extends number of interfaces in java.
- More than one extension is called “multiple inheritance”.
interface First
{
}
interface Second
{
}
interface Third extends First, Second
{
// Multiple inheritance
}
Question: Can’t we implement interface without using ‘implements’?
Answer: Interface is a standard set of specifications and can be implemented by any class.
/*
interface In
{
void m1();
void m2();
}
*/
class Test /*implements In*/
{
public void m1(){ }
public void m2(){ }
public static void main(String[] args)
{
Test obj = new Test();
obj.m1();
obj.m2();
}
}