did interface can implementation method ? i know its not
possible but my interviewer said its possible ..but how..?
any one have idea ???

Answer Posted / lakshmikanth

We can implement the method in the interface anonymously.

for example :

public class TestInterface {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
A o1= new A(){
public void f()
{
System.out.println("testing ....");
}
};
o1.f();
}

}
interface A
{
void f();
}

please let me know our concerns .

Lakshmiakanth.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of garbage collectors in java?

815


What is meant by data hiding in java?

854


When should I use singleton pattern?

808


What are the four versions of java?

768


What is the synchronized method modifier?

851


What is the benefit of lambda expressions?

737


State some situations where exceptions may arise in java?

842


how to open and edit XML file in Weblogic???

1776


Why are the destructors for base class and derived class called in reverse order when the program exits

1937


What is the purpose of skeleton and stub?

816


Is string is a data type in java?

804


How does enum work in java?

782


Give the hierarchy of inputstream and outputstream classes.

819


When throw keyword is used?

793


What is meant by structural programming?

792