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
what is meant by abstract class?
What is the private method modifier?
What is method overloading with type promotion?
What is difference between string and stringbuffer?
What is autoboxing in java?
Can static method access instance variables ?
What is the gregoriancalendar class in java programming?
Explain wait(), notify() and notifyall() methods of object class ?
What is output buffer?
What do you mean by composition in java?
What is the default size of load factor in hashing based collection?
What is mean by encoding?
Define nashorn in java8.
What are the loops in java?
How does multithreading take place on a computer with a single cpu?