需要答案的给我留言
http://www.yztcedu.com
—by 超哥
每日一考—Day03
不定项选择题。(每题答案的个数不固定)
2的5次方的最快算法是下面哪个?
A、2 * 2 * 2 * 2 * 2
B、2 << 5
C、1 << 5
D、1 >> 5下面的代码片段执行后输出多少?
A、3
B、4
C、5
D、6int a = 2; int b = 3; int c = ++a >= b++ ? a++ : b++; System.out.println(c);
java语句有哪些结构?
A、顺序结构
B、循环结构
C、选择结构
D、跳转结构下面代码片段执行后输出什么?
A、你真坏
B、你真好
C、A和B都会输出
D、A和B都不会输出int a = 5; int b = 6; if(a++ < b--){ a--; System.out.println("你真好"); }else{ b++; System.out.printlln("你真坏"); }
在上题目中的代码执行结束后,a和b的值分别是多少?
A、a = 6 b = 6
B、a = 6 b = 7
C、a = 5 b = 7
D、a = 5 b = 5下面代码执行结果是( )
A、a
B、b
C、if中的条件必须是boolean表达式,所以编译错误
D、abpublic class Test{ public static void main(String[] args){ boolean bo1 = false; if(bo1 = true){ System.out.println("a"); }else{ System.out.println("b"); } } }
以下代码输出结果是( )
A、2
B、2 3
C、2 3 4
D、2 3 4 defaultpublic class Test{ public static void main(String[] args){ byte b = 2; switch(b){ case 1: System.out.println("1"); case 2: System.out.println("2"); case 3: System.out.println("3"); case 4: System.out.println("4"); break; default: System.out.println("default"); } } }
switch都支持哪些数据类型?
A、byte
B、short
C、long
D、枚举
E、double
F、String
G、int
H、char下面代码的输出几个*:
A、3个
B、1个
C、无数个
D、编译错误public class Test{ public static void main(String[] args){ for(byte b = 125; b < 128; b++){ System.out.pritnln("*"); } } }
下面代码运行结果多少*:
A、编译错误
B、无法确定
C、无数个(死循环)
D、运行错误public class Test{ public static void main(String[] args){ for(; ; ){ System.out.pritnln("*"); } } }
下面代码的循环体执行多少次?
A、1次
B、0次
C、无限次
D、编译错误public class Test{ public static void main(String[] args){ int a = 4; while(a == a++){ System.out.println("*"); } } }
下面代码的循环体执行多少次?
A、1次
B、0次
C、无限次
D、编译错误public class Test{ public static void main(String[] args){ int a = 4; while(a++ == a){ System.out.println("*"); } } }
- while循环和 do…while循环的区别是: ( )
A.没有区别,这两个结构任何情况下效果一样
B.while循环比 do…while循环执行效率高
C.while循环是先循环后判断,所以循环体至少被执行一次
D.do…while循环是先循环后判断,所以循环体至少被执行一次 下面代码的运行结果是:
A、0 1 2 3 4 5
B、0 1 3 4 5
C、0 1
D、编译错误public static void main (String[] args) { for(int i=0; i<=5; i++){ if(i==2){ continue; } System.out.println (i) ; } }
下面代码的运行结果是:
A、0 1 2 3 4 5
B、0 1 3 4 5
C、0 1
D、编译错误public static void main (String[] args) { for(int i=0; i<=5; i++){ if(i==2){ break; } System.out.println (i) ; } }