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
Is null an object in java?
What are the advantages of assembly language?
What are the disadvantages of using inner classes?
Why arraylist is not synchronized in java example?
Is java jre still free?
How do you compare objects in java?
Which collection is sorted in java?
Which method cannot be overridden in java?
What is thread safe singleton?
What is a conditional statement explain with example?
What is the numeric promotion?
What is immutable in java?
What is a newline character in java?
How to check if a list is sorted in java?
Can abstract class have private constructor?