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 modifiers may be used with an inner class that is a member of an outer class in java programming?
What is protected access modifier?
please send me hr interview questions in it industry
How do you create a first line indent?
What is console based application in java?
What is the difference between @before and @beforeclass annotation?
What is return type in java?
Why do people says “java is robust”?
Write a code to show a static variable?
What is the old name of java?
How to sort double array in java?
Is java platform independent?
What does int [] mean in java?
Is an empty arraylist null?
Can an interface be final?