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 are the different types of garbage collectors in java?
What is meant by data hiding in java?
When should I use singleton pattern?
What are the four versions of java?
What is the synchronized method modifier?
What is the benefit of lambda expressions?
State some situations where exceptions may arise in java?
how to open and edit XML file in Weblogic???
Why are the destructors for base class and derived class called in reverse order when the program exits
What is the purpose of skeleton and stub?
Is string is a data type in java?
How does enum work in java?
Give the hierarchy of inputstream and outputstream classes.
When throw keyword is used?
What is meant by structural programming?