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
What is the base class of all exception classes in java?
Why do we need wrapper class?
What is annotation in java?
What is the relationship between clipping and repainting under awt?
Give few difference between constructor and method?
Write a program in java to establish a connection between client and server?
Name few java 8 annotations ?
What do you mean by garbage collection used in java?
Is zero a natural number?
what are the disadvantages of indexes in oracle?
What is bubble sort in java?
What flag up means?
What is an error in java?
What are register variables what are the advantages?
Can we define a package statement after the import statement in java?