can you create interface instance ?
Answer Posted / nishant
hi Uday,what you've done is, created an annonymous inner
class which is the implementer class of the interface.Here
the refernce variable is of the interface but it is
referencing to the newly created annonymous inner class
instance.
Here the instanceof operator returns true because
annonymous inner class is the implementer of interface and
instanceof always returns true with the same class or its
super class(try using instanceof with Object class, it will
always return true,may the object be of any class).
| Is This Answer Correct ? | 14 Yes | 0 No |
Post New Answer View All Answers
What is the difference between class & object?
Explain about static imports in java?
How is garbage collection controlled?
What is a method in java?
What is a boolean field?
Given a singly linked list, determine whether it contains a loop or not without using temporary space?
What is difference between static and final?
Are arrays primitive data types?
Why array is used in java?
How an object is serialized in java?
Can private class be extended java?
What are data types in programming?
Differentiate between nested and inner class in java.
Can we create our own daemon thread?
What about abstract classes in java?