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 is the base class of all exception classes in java?

812


Why do we need wrapper class?

761


What is annotation in java?

809


What is the relationship between clipping and repainting under awt?

882


Give few difference between constructor and method?

755


Write a program in java to establish a connection between client and server?

735


Name few java 8 annotations ?

808


What do you mean by garbage collection used in java?

826


Is zero a natural number?

788


what are the disadvantages of indexes in oracle?

2100


What is bubble sort in java?

862


What flag up means?

807


What is an error in java?

873


What are register variables what are the advantages?

706


Can we define a package statement after the import statement in java?

833