第五章单元测试
看下面一段语句块,执行结果是:
……
int res=0;
for(int i=1; i<=100; i++){
if(i%2==0)
continue;
res+=i;
}
System.out.println(res);
……
以下Java的条件、循环结构的写法,有输出效果、且没有错误的有哪些?
Java语言中,使用大括号包裹一块语句块,像for、if等循环、条件结构,都必须使用大括号包裹语句块。
continue用来退出循环。
以下关于程序调试的说法错误的是
A:1 B:5050 C:2550 D:2500
答案:2500
A:…… if(true){ System.out.println("hello"); } …… B:…… if(true) System.out.println("hello"); …… C:…… if(true); { System.out.println("hello"); } …… D:…… while(1){ System.out.println("hello"); } ……
A:错 B:对
A:错 B:对
A:throw可以抛出错误 B:assert断言功能常用于单元测试 C:exception类需要自定义 D:try...catch...可以捕获错误
温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!