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
How many types of design patterns are there?
Which is a valid identifier?
Why heap memory is called heap?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
Do you know how to reverse string in java?
Difference between method overloading and method overriding in java ?
What is the difference between abstract classes and interfaces?
Java Compiler is stored in JDK, JRE or JVM?
What do you mean by an object in java?
What are different type of exceptions in java?
What is wrapper class example?
Is empty in java?
How transient variable is different from volatile variable?
Is java a utf 8 string?
How do you identify if jvm is 32-bit or 64-bit from java program?