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 do you mean by inner class in java?
How many bytes are there?
What is difference between char array and string?
What do you mean by ordered and sorted in collections in java?
Explain the polymorphism principle?
Define interface in java?
What is a generic code?
What is Mutex (Mutual Exclusion Object) ?
What language is pass by reference?
explain copyonwritearraylist and when do we use copyonwritearraylist?
how to convert Java project into Maven ?
What is the difference between access specifiers and access modifiers in java? 16
Give me an example of array and linked list? Where they can be used?
What are the advantages of unicode?
What is cr keyboard?