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
Can I declare class as static or private?
Can you sort a string in java?
Why java uses the concept of the string literal?
What does || || mean in math?
Can an interface have a class?
what is singleton in java?
What is function overriding and overloading in java?
What is the disadvantage of synchronization?
What are peerless components?
Can we override static methods in java?
Is null an object in java?
If we don’t want some of the fields not to serialize how to do that?
What are default methods ?
What is a method type?
What is the concatenation operator in java?