天天看点

java面试题个归纳

  1. 如下代码
public class Test {
public int aMethod() {
static int i = 0;
i++;
return i;
}
public static void main (String args[]) {
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
输出结果是什么? ( D)
A. 0
B. 1
C. 2
D. 编译失败