• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Boone's mock exam Q47

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a queston from Barry Boone's exam Q47.
the code below will NOT compile because Dots class didn't implement the void run() from Runnable. so Dots must be an abstract class. and answer a says prints nothing. I think it should say won't compile. any comments ?
chun
Q47-------------------------------------
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("-");
}
}

a.nothing
b.100 dots (.)
c.200 dots (.)
d.100 dashes (-)
e.100 dots (.) and 100 dashes(-)
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also think it should say won't compile.
Amit
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it will not compile as Dots class does not define run() in it.
thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic