can you create interface instance ?
Answer Posted / kishore emani
Hi Anil, In this case uday sounds good!
As per your consideration if it is an anonymous class then
just remove that interface from our application and try to
compile it won't compile that code.
Here Test is an interface, for which to create the object
we need to provide the complete implementation for that
interface the same thing which uday did.
and again u check it if(t instanceof Test)
it is returning true that means t is an instance for Test.
and here the object is creating in the heap.
at finally here an instance is created for an interface.
| Is This Answer Correct ? | 4 Yes | 7 No |
Post New Answer View All Answers
What is fail fast in java?
What is the difference between char and char *?
What are the two types of java?
What is array pointers ?
What are the differences between throw and throws?
What is t in generics in java?
Can you inherit a constructor java?
What’s the difference between the methods sleep() and wait()?
Can we have a method name same as class name in java?
Define linked list and its features with signature?
What is %02d?
What is public static void main?
Why do we create public static method in java?
What is java ceil?
Can a class be declared as protected?