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
What are the restrictions imposed on method overriding?
What is included in core java?
Which programming language is best in future?
Explain abstract class in java?
What a static class can contains?
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread
Why is it important to initialize a variable?
What is the symbol for space?
What is thread start?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?
What do you mean by platform independence? What is an interface?
How can a gui component handle its own events?
What is %02d?
What is the use of jtable?
What do you understand by garbage collection in Java? Can it be forced to run?