A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Reg. Runnable
Angela Narain
Ranch Hand
Joined: Apr 14, 2001
Posts: 327
posted
Sep 24, 2001 02:16:00
0
Another example from Barry Boone's exam :
class Dots implements Runnable { DotThread t; public static void main(String[] args) { Dots d = new Dots(); d.t = new DotThread(); } public void init() { t.start(); t = new DashThread().start(); } } class DotThread extends Thread { public void run() { for (int index = 0; index < 100; index++) System.out.print("."); } } class DashThread extends Thread { public void run() { for (int index = 0; index < 100; index++) System.out.print("-"); } } 1.nothing 2.100 dots (.) 3.200 dots (.) 4.100 dashes (-) 5.100 dots (.) and 100 dashes(-)
The correct answer is 1
But it should get compile time error as Dots implements
Runnable but does not provide the run() method.
james hoskins
Ranch Hand
Joined: Jun 28, 2001
Posts: 31
posted
Sep 24, 2001 03:19:00
0
hello angela,
you are right, no run() method means Dots must be declared abstract.
kind regards,
james
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Reg. Runnable
Similar Threads
Boone's mock exam Q47
Boonie's Exam: 47 - mistake??
Is there any mistake in this Thread code.
Confused with mock exam question
reg a mock exam
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter