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 do heavy weight components mean in java programming?
Tell me the latest versions in java related areas?
What is the default access specifier for variables and methods of a class?
Is empty set an element of empty set?
How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?
Explain runtime exceptions?
Can I override protected method in java?
what do you mean by classloader in java?
What is flag in python?
How do you sort arrays in java?
How define set in java?
How you can force the garbage collection?
What is the use of isempty in java?
What is meant by method?
Does string is thread-safe in java?