Answer Posted / amit kumar gautam
Though it is correct that interfaces are basically used for
obtaining the dynamic resoulution of the Method and they
usually can not be instantiated but it is also possible to
instantiate the same in case of anonymous classes and it
works fine.......
class Amit
{
void addCode()
{
Runnable rr=new Runnable()
{
public void run()
{
System.out.print("This is Amit")
}
};
Thread tt=new Thread(rr);
tt.start();
}
}
class Check
{
static public void main(String[]amit)
{
new Amit().addCode();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
When is an object subject to garbage collection?
What is the destroy method?
How to make a non daemon thread as daemon?
When should I use singleton pattern?
Is class is a data type?
Is char a data type in java?
What is difference between string and new string?
Explain the differences between abstraction and encapsulation?
Can you explain the final method modifier?
What is data movement?
What is the advantage of functional interface in java 8?
Is string is a class in java?
Can a static class implement an interface?
How can we create an immutable class in java?
What an i/o filter in java programming?