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 is the importance of hashcode() and equals() methods?
What is array class in java?
Can size_t be negative?
How do you identify independent and dependent variables?
Can a class be protected in java?
Explain about the interpreter in java?
How many ways can we create singleton class?
What is a class object?
What is difference between filereader and bufferedreader?
Explain the importance of thread scheduler in java?
Why does java doesnt suuport unsigned values?
What is a byte string?
What are parsing rules?
What is oops in java?
How does remove work in java?