题目内容

有如下程序:public class Main {public static void main(String[] args) {Scanner sca = new Scanner(System.in);int x = sca.nextInt();if(x>3){System.out.println("231");}else if(x>-3){System.out.println("123");}else{System.out.println("321");}}}当打印“123”,x的取值范围是:

A. x>3
B. x>-3
C. x<=-3
D. x<=3 && x>-3

查看答案
更多问题

给定下面的代码,哪些行会导致错误?1) String str = null;2) if ((str != null) & (str.length() > 10)) {3) System.out.println("more than 10");4) }5) else if ((str != null) && (str.length() < 5)) {6) System.out.println("less than 5");7) }8) else { System.out.println("end"); }

A. line 1
B. line 2
C. line 5
D. line 8

下面的程序段执行了多少次循环:int k=10;while(k>3)k=k-1;

A. 死循环
B. 1
C. 3
D. 7

下列循环体执行的次数是:int x=10, y=30;do{y -= x;x++;}while(x++

A. 1
B. 2
C. 3
D. 4

设变量k已定义,以下由while语句构成的循环执行的次数是( )while(true) k++;

A. 无限次
B. 有语法错误,不能执行
C. 一次也不执行
D. 执行1次

答案查题题库