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
Is char * a string?
What are the basic concepts of OOPS in java?
Why is java so important?
define the terminology association.
What is a lambda expression ? What's its use ?
Can we declare an interface as final?
What is the difference between the reader/writer class hierarchy and the inputstream/outputstream class hierarchy in java programming?
What class of exceptions are generated by the java run-time system?
Compare Mutex and Semaphore in java.
Explain jdk, jre and jvm?
What is difference between char array and string?
Write java program to reverse string without using api?
What is stringwriter?
What is the purpose of a parameter?
How do you define a method?