-->
当前位置:首页 > 题库

单选题:Given:

Luz5年前 (2021-05-10)题库1072
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