单选题:Given:
Given:
```Java
class Foo {
int total;
static class Increment extends Thread {
public void run() {
++total;
}
}
}
```
Which of the following changes to the code will make it valid? @[B](2)
A. Add a semicolon at the end of the inner class definition.
B. Get rid of the static keyword.
C. Declare the variable total as final.
D. Nothing. The code compiles and runs fine.
A.Add a semicolon at the end of the inner class definition.
B.Get rid of the static keyword.
C.Declare the variable total as final.
D.Nothing. The code compiles and runs fine.
答案:B
```Java
class Foo {
int total;
static class Increment extends Thread {
public void run() {
++total;
}
}
}
```
Which of the following changes to the code will make it valid? @[B](2)
A. Add a semicolon at the end of the inner class definition.
B. Get rid of the static keyword.
C. Declare the variable total as final.
D. Nothing. The code compiles and runs fine.
A.Add a semicolon at the end of the inner class definition.
B.Get rid of the static keyword.
C.Declare the variable total as final.
D.Nothing. The code compiles and runs fine.
答案:B