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 .

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Where is singleton pattern used?

710


Can singleton class be cloned?

767


how to create constants in java?

791


Explain the difference between treeset and treemap in java?

711


How a variable is stored in memory?

689






How transient variable is different from volatile variable?

731


How is string immutable in java?

713


What is the use of join method?

752


What are constructors in java?

734


What is Applet Stub Interface ?

2131


What is the purpose of tostring() method in java?

735


What is lexicographically smallest string?

757


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

823


Print Vertical traversal of a Binary Tree.

761


What is length in java?

731