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 local class in java?
What is externalizable interface?
Which methods cannot be overridden in java?
What is OOP's Terms with explanation?
Write a program to solve producer consumer problem in java?
Can abstract class have private constructor?
What is parsing and its types?
How can you share data between two thread in Java?
What does nextint () do in java?
Explain access modifiers in java.
Why synchronization is important in java?
State the significance of public, private, protected class?
Is it necessary for the port addresses to be unique? Explain with reason.
Can we define package statement after import statement in java?
What are 3 data types?