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
Write a factorial program using recursion in java?
What does java stand for?
Can you sort a list in java?
What is use of static method?
What is instanceof keyword?
What is the difference between arraylist and hashset in java?
What do you understand by looping in java? Explain the different types of loops.
What is the program compilation process?
What do you understand by final value?
Is java programming easy?
Why pass by reference is not possible in java?
What is string immutability?
How do you remove spaces in java?
Is 0 a prime number?
What is meant by anonymous class?