can you create interface instance ?
Answer Posted / mallesh
hey uday that is not creating intance for Test interface ,
ur implementing the interface using anonymous class
(unknoun class)
public class Test2 {
public static void main(String[] args) {
Test2 t=new Test2();
Runnable r=new Runnable() {
public void run() {
System.out.println("Hi");
}
}; r.run();
System.out.println(r.getClass().getName().toString());
System.out.println(t.getClass().getName().toString());
}
}
Output:Hi
Test2$1
Test2
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can we serialize arraylist in java?
How do I start learning java?
When super keyword is used?
What is an argument java?
What is keyword and identifier?
How would you convert bytes to string?
What is lazy initialization in java?
What is the difference between an array and an array list?
when to use ArrayList and when to use HashMap in webApplication.
What are the elements of java?
What does it mean that a class or member is final?
Who is the owner of java?
Does hashset allow duplicates in java?
Can we return null in java?
What are the 4 types of characters?