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 are some characteristics of interference class?
Can an interface have a constructor?
What are three types of loops in java?
What is the basic concept of java?
Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.
What are the advantages of assembly language?
Can inner class final?
Do we need to manually write Copy Constructor?
What are the main differences between notify and notifyAll in Java?
What will be the initial value of an object reference which is defined as an instance variable?
What is the difference between stream and buffer?
How many types of flags are there?
What is boolean query?
What is parsing in java?
How to instantiate static nested classes in java?