本学校计算机系java程序设计教学使用的教案
c
请问哪个语句是正确的? A、 args[0] = "MyTest a b c" B、args[0] = "MyTest" C、args[0] = "a" D、args[1]= 'b'
答:三个参数"a" "b" "c" 存在args[] 中,且 args[0]= "a", args[1]= "b", args[2]= "c". 故C D正确。
16、 已知如下代码: public class Test {
long a[] = new long[10];
public static void main ( String arg[] ) { System.out.println ( a[6] ); } }
请问哪个语句是正确的? A、Output is null. B、Output is 0.
C、When compile, some error will occur. D、When running, some error will occur. 答:数据创建之后每个下标量都已初始化,且初始化的值为0。B 正确。
17、 已知如下代码: boolean m = true; if ( m = false )
System.out.println("False"); else
System.out.println("True"); 执行结果是什么? A、False B、True C、None
D、An error will occur when running. 答:= 是赋值操作符, == 是比较操作符. 本题中将false赋值给m. A 正确。
18、 已知如下代码: public class Test {
public static void main(String arg[]) {
int i = 5; do {
System.out.println(i); } while (--i>5)
System.out.println("finished"); } }
执行后的输出是什么? A、 5 B、4 C、6
D、Finished E、None
答: do/while循环中的表达式至少执行一次. 如果循环的条件不满足,则循环一次后停止,否则一直循环直到条件不满足。A,D正确。
19、 下面代码执行后的输出是什么? outer: for(int i=0;i<3; i++) inner: for(int j=0;j<2;j++) {
if(j==1) continue outer;
System.out.println(j+ ?and ?+i); }
A、 0 and 0 B、0 and 1 C、0 and 2 D、1 and 0 E、1 and 1 F、1 and 2 G、2 and 0 H、 2 and 1