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
Difference between error and exception
How do I run java on windows?
Is a char always 1 byte?
What is main method?
What does \ mean in regex?
What is static variable with example?
Which collections are thread safe in java?
What is use of valueof () in java?
Can we have more than one package statement in the source file?
how its run?
Why do we create public static method in java?
What carriage return means?
Can a method be static?
If a variable is declared as private, where may the variable be accessed?
Is ruby built on java?