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
How we can make copy of a java object?
What type of language is java?
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator
Is 0 an even number?
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
Can an interface have a class?
Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain
When will we use them?
What are the important methods of java exception class?
How do I convert a string to an int in java?
What is class??
Does anyone still use java?
Is there any difference between nested classes and inner classes?
Why scanner is used in java?
What methodology can be employed to locate substrings inside a string?