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
Tell some latest versions in JAVA related areas?
What does || mean in code?
What is the final method?
Can finally block be used without a catch?
What is the difference between logical data independence and physical data independence?
List some features of the abstract class.
Is empty string in java?
What is the purpose of main function in java?
What is the purpose of a default constructor?
What are the topics in advance java?
How strings are created in java?
Which is fastest collection in java?
What will happen if a thrown exception is not handled?
How to handle a web browser resize operation?
What is java util?