Javatpoint Logo

If two interfaces have same method, how to handle that method in a class implementing those two interfaces?

By: venkat*** On: Tue Apr 08 22:16:32 IST 2014     Question Reputation5 Answer Reputation19 Quiz Belt Series Points0  24User Image
Explain please
Thank You...
Up0Down
core java  x  328Tags

 
interface One
{
public void m1();
}
interface Two
{
public void m1();
}

class Three implements One,Two
{
public void m1()
{
System.out.println("implementation");
}

}

Conclution:
----------

If two interfaces(One,Two) having a method(m1) with same signature and same return type, in implementation class(Three) we can provide implementation for only one method.
Image Created1Down

By: [email protected] On: Wed Apr 09 00:14:45 IST 2014 Question Reputation16 Answer Reputation29 Belt Series Points0 45User Image
Are You Satisfied :0Yes0No
 
if you are using two interface with same method one will be called and you will not know which one it is.Image Created0Down

By: [email protected] On: Wed Apr 09 13:17:27 IST 2014 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :0Yes0No