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 use of beaninfo?
What is main function purpose?
Write a program to print count of empty strings in java 8?
What are different types of arrays?
What is the size of int in 64-bit jvm?
What initialize variables?
What happens to a static var that is defined within a method of a class?
How many times finalize method will be invoked? Who invokes finalize() method in java?
Which is better list or arraylist in java?
What is thread start?
Explain public static void main(string args[]) in java.
What is use of valueof () in java?
What does math floor () do?
Can we rethrow the same exception from catch handler?
Is age a discrete variable?