This is my code i have a doubt

class ab implements a,b
{

public void add()
{
System.out.println("Hi")
}
}

interface a
{
public void add();
}

interface b
{
public void add();
}

in this code i have two interface implemented in the class
has same method.just i want to know which method of
interface implemented in the class. interface a or interface
b? confused me .

Answers were Sorted based on User's Feedback



This is my code i have a doubt class ab implements a,b { public void add() { System.out.pri..

Answer / gohil

You can dynamically implement any of the interface
Ex
a intAImpObj= new ab();
b intBImpObj= new ab();

In above case intAImpObj is the implementation of a
interface and intBImpObj is the implementation of b interface

Is This Answer Correct ?    0 Yes 0 No

This is my code i have a doubt class ab implements a,b { public void add() { System.out.pri..

Answer / narayana

There should be no confusion. Since both the interfaces are
been implemented and both have the same method signature and
return type, it will
work fine and will take any of the method.
Since there is no implementation in Interfaces it is
difficult to know which interface the method is read.

Is This Answer Correct ?    0 Yes 0 No

This is my code i have a doubt class ab implements a,b { public void add() { System.out.pri..

Answer / kanu butani

There should be no confusion. Since both the interfaces are
been implemented and both have the same method, it will
work fine and will take any of the method.
Since there is no implementation in Interfaces it is
difficult to know which interface the method is read.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More Core Java Interview Questions

What is the biggest integer?

0 Answers  


How to make a non daemon thread as daemon?

0 Answers  


How to add menushortcut to menu item?

0 Answers  


what is default layout of JFrame class?

6 Answers  


what is request dispatcher and how does it work?

2 Answers   CTS,






What variables are stored in stack?

0 Answers  


What is the difference between double and float variables in java?

0 Answers  


Which graphs are functions?

0 Answers  


Is it possible to override private or static method in java?

0 Answers  


What is dynamic array in java?

0 Answers  


Define immutable object?

0 Answers  


What is the protocol is used in type4 driver?

4 Answers   CMC,


Categories