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 / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we clone singleton class in java?

727


What is ternary operator in java?

823


What does function identity () do?

725


How to obtain a performance profile of java program

768


Can we create an object of private class?

748


Are constructors methods?

773


What is the difference between an array and an array list?

737


What is functional interface in javatpoint?

732


Why for each loop is used?

760


How to do encapsulation in java?

826


What is difference between iterator access and index access?

853


Why do we need hashmap in java?

776


Why java is used everywhere?

765


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

767


Is there any case when finally will not be executed?

728