下列程序段的运行结果为( )int index = 1;int foo[] = new int[3];int bar = foo[index];int baz = bar + index;
A: baz 的值为 0
B: baz 的值为 1
C: baz 的值为 2
D: 抛出一个异常
A: baz 的值为 0
B: baz 的值为 1
C: baz 的值为 2
D: 抛出一个异常
举一反三
- 下面程序段的运行结果为() int index=1; int[] foo=new int[3]; int bar=foo[index]; int baz= bar+index;
- int index = 1; int [] foo = new int [3]; int bar = foo [index]; int baz = bar + index; What is the result?() A: Baz has the value of 0 B: Baz has the value of 1 C: Baz has the value of 2 D: An exception is thrown. E: The code will not compile.
- 关于以下初始化序列的执行结果的说法正确的是( )。 int index=1; int[] foo=new int[3]; int bar=foo[index]; int baz=bar+index; A: baz的值为0 B: baz的值为1 C: 编译通过,但产生异常 D: 编译不能通过
- int index = 1; int foo = new int ; int bar = foo [index]; int baz = bar + index; What is the result?() A: Baz has the value of 0 B: Baz has the value of 1 C: Baz has the value of 2 D: An exception is thrown. E: The code will not compile.
- 下列程序执行后,baz的值应是( )。 int index=1; int fox[ ]=new int[3]; Int bar=fox[index]; int baz:bar+index; A: 0 B: 1 C: 2 D: 编译错误