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 are destructors defined in java?
What is comparable and comparator interface? List their differences
Implementations of set interface?
What is %d in printf?
What is a private class in java?
What are the legal parameters?
Is boolean a data type in java?
What is object-oriented paradigm?
What is a qms manual?
What is an exception in java?
What will be the output of round(3.7) and ceil(3.7)?
What are the differences between abstract class and interface?
What is memory leak and how does java handle it?
What is core java called?
What is callablestatement? How you can call stored procedure to pass in parameter?