5
Reply

The implemented method would be of which interface ? There are two interfaces B and C each having the same method public m1() class A implements B and C. If class A has to implement method m1, the implemented method would be of which interface ?

Gul Md Ershad

Gul Md Ershad

9y
1.5k
0
Reply

    If you give Simply give m1() implementation then it is show compile time error due to conflict . you must give implemetation as B.m1() or C.m1() then it will target B or C interface respectively.

    When class A will implement method m1, it will be implementing both interfaces. When we create object of A with reference of interface B, then it will be implementation of m1 of B. B objB = new A();objB.m1();If we need to implement both separately, we need to mention interface with method name like this..class A : B, C{void B.m1(){throw new NotImplementedException();}void C.m1(){throw new NotImplementedException();} }

    Use B.m1() and C.m1()

    Use B.m1() and C.m1()

    As long as they have the same signatures the compiler will consider them as one method. In case that one of them has a different return type it would result in compile error. Overridden method will be applicable for both the interface.