can you create interface instance ?

Answer Posted / kishore emani

Hi Anil, In this case uday sounds good!
As per your consideration if it is an anonymous class then
just remove that interface from our application and try to
compile it won't compile that code.
Here Test is an interface, for which to create the object
we need to provide the complete implementation for that
interface the same thing which uday did.
and again u check it if(t instanceof Test)
it is returning true that means t is an instance for Test.
and here the object is creating in the heap.
at finally here an instance is created for an interface.

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between error and exception

5001


How do I run java on windows?

525


Is a char always 1 byte?

502


What is main method?

535


What does \ mean in regex?

619






What is static variable with example?

557


Which collections are thread safe in java?

474


What is use of valueof () in java?

553


Can we have more than one package statement in the source file?

637


how its run?

563


Why do we create public static method in java?

576


What carriage return means?

527


Can a method be static?

520


If a variable is declared as private, where may the variable be accessed?

546


Is ruby built on java?

529