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
How can we achieve thread safety in java?
What is string [] args?
How would you convert bytes to string?
What does %d do in java?
What is a flag value?
Why main function is static?
What language is java written?
What is the purpose of a parameter?
What is data member in java?
What are thread groups?
What is difference between pointer and reference?
What is application tier?
What is the method to expand and collapse nodes in a jtree?
What is java full form?
What is the difference between yield() and sleep()?