分析以下程序:
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);
}
}
该程序执行结果为?
A 编译将失败
B 编译成功,执行后输出“0”
C 编译成功,执行后输出“1”
D 编译成功,执行后输出“2”
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);
}
}
该程序执行结果为?
A 编译将失败
B 编译成功,执行后输出“0”
C 编译成功,执行后输出“1”
D 编译成功,执行后输出“2”