can you create interface instance ?
Answer Posted / balibalo
to the writer of #29:
what you propose doesn't work because at line where you have t.wish(), Java tries to find the wish() method in the Object class (since t is of type Object). As it doesn't exist in that class, your program fails to compile.
Simple.
Uday version compiles because there is not type unconsistency, but it still is an anonymous class call, hence not a correct answer to the root question (answer being already given: NO, you cannot create an instance of an interface but you can create references of it).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can an integer be null java?
How do you compare two strings lexicographically?
What are the ways in which a thread can enter the waiting state?
What is meant by collection in java?
How to avoid memory leak in java?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
What is blank final variable?
Can we override the private methods?
what is server side caching?
What are static blocks in java ?
Is heap stored in ram?
Which is bigger float or double java?
Who developed java?
What is the lifetime and scope of a variable?
Can we create an object of private class?