can you create interface instance ?
Answer Posted / tathagata
hi uday
I also tried this to call a interface of Collection and try
to instantiated but it is not working.
import java.util.*;
interface Test
{
public void wish();
}
class a implements Test
{
public void wish()
{
System.out.println("I am fine");
}
}
class Main
{
public static void main(String[] args)
{
Collection c =new Collection()
{
boolean isEmpty()
{
return true;
}
};
System.out.println(c.isEmpty());
Test t=new Test()
{
public void wish()
{
System.out.println("output:
hello how r u");
}
};
if(t instanceof Test)
{
System.out.println("t is a instance
of Test");
}
t.wish();
a oba=new a();
oba.wish();
}
}
But it is not working please explain.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Explain garbage collection in java?
What are kinds of processors?
How to pass arraylist to stored procedure in java?
What is <> used for in java?
Can a singleton class be inherited?
Why static functions are used?
What is an infinite loop in java? Explain with an example.
What is run time allocation?
How strings are created in java?
What are the special characters?
What is meant by distributed application? Why are we using that in our application?
What are the disadvantages of object oriented programming?
What is the indent key?
What is the map interface in java programming?
What java is used for?