• 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

Another Question From JQuest Mock Exam...

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question reads: What can you write at the comment //A in the following code that writes the word "running" to the standard output?

class RunTest implements Runnable {
���public static void main(String[] args) {
������RunTest rt = new RunTest();
������Thread t = new Thread(rt);
������// A
���}
���public void run() {
������System.out.println("running");
���}
���void go() {
������start(1);
���}
���void start(int i) {
���}
}

The question asks for all valid options:
a. System.out.println("running");
b. t.start();
c. rt.start();
d. rt.start(1);
I get that a is correct, but why so b? The argument list doesn't match.
Thanks,
Barbara
[This message has been edited by Barbara Dyer-Bennet (edited September 17, 2000).]
[This message has been edited by Barbara Dyer-Bennet (edited September 17, 2000).]
[This message has been edited by Barbara Dyer-Bennet (edited September 17, 2000).]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
refered to
...jdk1.2.2/docs/api/java/lang/Thread.html#start()
public void start()
Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
call start() then call run(), so "running" is print out
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic