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
Define nashorn in java8.
What is the function of character?
What is difference in between java class and bean?
What are the important features of Java 10 release?
What is a null point?
What is protected access modifier?
What is class level lock ?
Why singleton pattern is better than creating singleton class with static instance?
What is the public method modifier?
What is an immutable class?
When do we use synchronized methods in java?
When parseint method can be used?
What is the point of java?
how we can make a write-only class in java?
why using interface interface ?