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

How can we achieve thread safety in java?

691


What is string [] args?

570


How would you convert bytes to string?

572


What does %d do in java?

588


What is a flag value?

523






Why main function is static?

683


What language is java written?

544


What is the purpose of a parameter?

539


What is data member in java?

513


What are thread groups?

580


What is difference between pointer and reference?

514


What is application tier?

540


What is the method to expand and collapse nodes in a jtree?

622


What is java full form?

542


What is the difference between yield() and sleep()?

550