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 the importance of finally block in exception handling?
What is meant by object oriented programming – oop?
Which package has light weight components in java programming?
What is void in java?
What is the purpose of using break in each case of switch statement?
Can two objects have same hashcode?
I want to re-reach and use an object once it has been garbage collected. How it's possible?
What are the differences between stringbuffer and stringbuilder?
How to convert string to char and vice versa?
What is rule of accessibility in java?
How many types of parsers are there?
What is the purpose of using the java bean?
What is the use of inner class?
Can a method inside a interface be declared as final?
Is a boolean 1 bit?