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
What happens if an exception is throws from an object's constructor?
How are java objects passed to a method and what are native methods?
Explain the differences between static and dynamic variables?
How do you use parseint in java?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
Explain notify() method of object class ?
Why wait and notify methods are declared in object class?
What is array length in java?
What is the difference between sop and work instruction?
what is meant wrapper classes?
Why is java called java?
What is parsing a sentence?
What is pass by value?
Why we used vector class?
What is Recursion Function?