Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


Can you extend more than one interface?

Answers were Sorted based on User's Feedback



Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Can you extend more than one interface?..

Answer / jag

s we can

Is This Answer Correct ?    2 Yes 3 No

Can you extend more than one interface?..

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

Can you extend more than one interface?..

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

Post New Answer



More Core Java Interview Questions

Can we override private methods?

0 Answers  


what are class,constructor and primitive data types?

2 Answers   IBM,


What is default locale java?

0 Answers  


What does n mean?

0 Answers  


What is size of int in java?

0 Answers  






What is incompatible types in java?

0 Answers  


while creating thread why we extend thread class

2 Answers  


What is the multi-catch block in java?

0 Answers  


What are the standards to place package statement within a source code file?

1 Answers  


Is age a discrete variable?

0 Answers  


what are different ways in which a thread can enter the waiting state? : Java thread

0 Answers  


In Serialization, whether you will use Static variables?

3 Answers   HCL,






Categories