nishant tyagi


{ City } new delhi
< Country > india
* Profession * student
User No # 17393
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 14
Users Marked my Answers as Wrong # 0
Questions / { nishant tyagi }
Questions Answers Category Views Company eMail




Answers / { nishant tyagi }

Question { TCS, 66317 }

can you create interface instance ?


Answer

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