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 main advantage of passing argument by reference?
What is the dot operator?
Is integer passed by reference in java?
What classes of exceptions may be thrown by a throw statement?
What is final access modifier in java?
Why Java is not pure Object Oriented language?
How is hashset defined in java?
What is a numeric format?
What is stack example?
What is garbage collection? Can it be forced to run?
Is map sorted in java?
What does this () mean in constructor chaining concept?
Is null a string?
What is api data?
What is bufferedreader in java?