Can you extend more than one interface?
Answers were Sorted based on User's Feedback
Answer / ranganathkini
An interface can extend 1 or more interfaces. Though this
kind of extension mechanism is limited for classes extending
classes. It is not true for interfaces. Please observe
Interface3 in the following example:
interface Interface1 {
void method1();
}
interface Interface2 {
void method2();
}
interface Interface3 extends Interface1, Interface2 {
void method3();
}
public class InterfaceTest implements Interface3 {
public void method1() {
}
public void method2() {
}
public void method3() {
}
public static void main( String[] args ) {
}
}
Is This Answer Correct ? | 67 Yes | 3 No |
Answer / vijayakumar chinnasamy
There is no limit for interface extends. One interface can
extends any number of interfaces.
interface inter1 { }
interface inter2 { }
interface interN { }
interface ExtendsInterface extends inter1,inter2,... , interN {
}
Is This Answer Correct ? | 31 Yes | 4 No |
Answer / ganesh
we can extends one or more interfaces by using an interface.
i.e)Multiple inheritance is available in case of interfaces.
we can't extends an interface by using a class,but we able
to implemented.
Sytax:
1)interface interfacename1 extends interface2 //true
2)interface interfacename1 extends
interface2,interfacename2,..............interfacenamen //true
Is This Answer Correct ? | 16 Yes | 5 No |
Answer / swapnil bhosale
hey you all my friends ,we can not extends interface ,we can only implements it,is it true we can implement more than one
interface ,but can not extends it (not single not more)
run the following code so you could understand difference between extends and implements keyword
//code using extends keyword
import java.io.*;
interface A{}
interface X{}
interface Y{}
class ExDemo extends A,X,Y
{
public static void main(String arg[])
{
int a;
System.out.println("hey it works");
}
}
//code using implements keyword
import java.io.*;
interface A{}
interface X{}
interface Y{}
class ExDemo implements A,X,Y
{
public static void main(String arg[])
{
int a;
System.out.println("hey it works");
}
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / manish kushwaha
Hi All,
As we all know java is not complete OOps language the reason
behind this is java does not support multiple inheritance,
to avoid this draw back of java sun introduce interface
alomg with few new concept.
So 110% sure that we can implements and we can extends as
well more than one interface.
Scenarios:
1) in term of subclass
interface i1{
void mi1();
}
interface i2{
void mi2();
}
now
Case 1:
public class MultipleImplements implements i1,i2{
// now here we need t implement all methods available in i1
and i2 (restricted)
public void mi1(){
System.out.println("Interface i1 mthod");
}
public void mi2(){
System.out.println("Interface i2 mthod");
}
}
Case 2:
interface i3 extends i1,i2{
// here use can define more method and you can not over ride
i1 and i2 method because you can not method body in interface so
String mi3();
}
Conclusion: 110% you can extend and implement more than one
interface
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / rajeshbonepalli
An interface can extend other interfaces, just as a class
can extend or subclass another class. However, whereas a
class can extend only one other class, an interface can
extend any number of interfaces. The interface declaration
includes a comma-separated list of all the interfaces that
it extends.
interface Sameinterface1 { }
interface Sameinterface2 { }
interface Sameinterface3 { }
....
...
interface SameinterfaceN { }
interface Sameinterface4 extends
Sameinterface1 ,Sameinterface2 ,...Sameinterface3 ,
SameinterfaceN {
}
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ashokmail.java@gmail.com
interfaces are implementing not extends. We can implements
more than one interfaces
Is This Answer Correct ? | 18 Yes | 35 No |
Answer / a srinivas rao
we cannot extended INTERFACES,only can implement
INTERFACES.java allows you to implement more than one
INTERFACE.
Is This Answer Correct ? | 8 Yes | 38 No |
Does java trim remove newline?
Why java does not support pointers?
Is char a data type in java?
Can a class be subclass of itself?
What is hash in java?
How can an exception be thrown manually by a programmer?
Can we inherit the constructor in a Class?please give one example.
What is object english?
How do you check if a character in a string is a digit or letter?
How is a structure different from array ?
What is unicode datatype?
What is the final keyword in java?