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
Explain about interrupt() method of thread class ?
Is this valid in java ? Can we instantiate interface in java?
Is map sorted in java?
What is thread count in java?
What is string and example?
Explain about narrowing conversion in java?
What is data object example?
Can the interface be final?
Can I use % with real numbers?
Can we have two main methods in a java class?
How big is a pointer?
define the terminology association.
What is the history of java?
What are the rules for naming an array?
What is package private scope in java?