gudii9
asked on
thread program
>>What will happen when you attempt to compile and run this code?
public class Runt implements Runnable{
public static void main(String argv[]){
Runt r = new Runt();
Thread t = new Thread(r);
t.start();
}
public void start(){
for(int i=0;i<100;i++)
System.out.println(i);
}
}
1) Compilation and output of count from 0 to 99
2) Compilation and no output
3) Compile time error: class Runt is an abstract class. It can't be instantiated.
4) Compile time error, method start cannot be called directly
Answer
3) Compile time error: class Runt is an abstract class. It can't be instantiated.
The class implements Runnable but does not define the run method.
I have not understood above question and answer clearly from link
http://www.jchq.net/certkey/0701certkey.htm
>>class Runt is an abstract class
Runt never mentioned as abstract any where.
Any ideas, resources, links, sample code highly appreciated. thanks in advance.
public class Runt implements Runnable{
public static void main(String argv[]){
Runt r = new Runt();
Thread t = new Thread(r);
t.start();
}
public void start(){
for(int i=0;i<100;i++)
System.out.println(i);
}
}
1) Compilation and output of count from 0 to 99
2) Compilation and no output
3) Compile time error: class Runt is an abstract class. It can't be instantiated.
4) Compile time error, method start cannot be called directly
Answer
3) Compile time error: class Runt is an abstract class. It can't be instantiated.
The class implements Runnable but does not define the run method.
I have not understood above question and answer clearly from link
http://www.jchq.net/certkey/0701certkey.htm
>>class Runt is an abstract class
Runt never mentioned as abstract any where.
Any ideas, resources, links, sample code highly appreciated. thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If so, it should implement
public void run() method
If it does not (like in this code) it will immedaitely generate compiler error