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
Why java is call by value?
What a static class can contains?
What super () does in java?
why are there separate wait and sleep methods? : Java thread
What is the difference between stringbuffer and stringbuilder class?
What do you mean by order of precedence and associativity?
write a program that list all permutations of ABCDEF in which A appears before B?
What is linked hashmap and its features?
What are the differences between c++ and java?
Lowest Common ancestor in a Binary Search Tree and Binary Tree.
What is a data structure java?
What is stream api in java8?
What is the difference between normal report & matrix report?
Define iterator and methods in iterator?
How java uses the string and stringbuffer classes?