单选题:Given:
Given:
```Java
class Century implements Runnable {
public void run() {
for ( int year = 1900; year < 2000; year++ ) {
System.out.println(year);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
System.out.println(“Happy new millennium!”);
}
}
public class CountUp {
public static void main(String[] args) {
Century ourCentury = new Century();
// put your line here
}
}
```
There’s a missing line in CountUp.main(), which is to begin the thread defined in Century. Which is the proper code:
@[D](2)
A. `Thread t = new Thread(this); t.start();`
B. `Thread t = new Thread(ourCentury); ourCentury.start();`
C. `Thread t = new Thread(this); t.start(ourCentur);`
D. `Thread t = new Thread(ourCentury); t.start();`
A.`Thread t = new Thread(this); t.start();`
B.`Thread t = new Thread(ourCentury); ourCentury.start();`
C.`Thread t = new Thread(this); t.start(ourCentur);`
D.`Thread t = new Thread(ourCentury); t.start();`
答案:D
```Java
class Century implements Runnable {
public void run() {
for ( int year = 1900; year < 2000; year++ ) {
System.out.println(year);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
System.out.println(“Happy new millennium!”);
}
}
public class CountUp {
public static void main(String[] args) {
Century ourCentury = new Century();
// put your line here
}
}
```
There’s a missing line in CountUp.main(), which is to begin the thread defined in Century. Which is the proper code:
@[D](2)
A. `Thread t = new Thread(this); t.start();`
B. `Thread t = new Thread(ourCentury); ourCentury.start();`
C. `Thread t = new Thread(this); t.start(ourCentur);`
D. `Thread t = new Thread(ourCentury); t.start();`
A.`Thread t = new Thread(this); t.start();`
B.`Thread t = new Thread(ourCentury); ourCentury.start();`
C.`Thread t = new Thread(this); t.start(ourCentur);`
D.`Thread t = new Thread(ourCentury); t.start();`
答案:D