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
What is mutable object and immutable object?
What is the properties class?
In how many ways we can do exception handling in java?
What are the two types of java programming?
Can we declare a static variable inside a method?
Explain about doubly linked list
EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.
What does t in java mean?
What does I ++ mean?
What is the size of int in 64-bit jvm?
What are selection structures?
What is difference between stringbuffer and string?
What is abstract class? Explain
Is java platform independent?
What is the difference between the boolean & operator and the && operator in java programming?