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 you mean by scope of variable?
What is a vararg?
Is hashmap thread safe?
How do you do a line break in java?
Does java map allow duplicates?
Why can't we override private static methods?
What is a locale?
What is meant by oops concept in java?
What is type parameter in java?
What carriage return means?
is there a separate stack for each thread in java? : Java thread
What is a war file?
Why java is called not pure object oriented language?
Does java support function overloading, pointers, structures, unions or linked lists?
What is the difference between access specifiers and access modifiers in java?