问题
单项选择题
给出下列代码片断:
if(x>0) System.out.println("first");
else if(x>-3)System.out.println("second");
else System.out.println("third");
请问x处于什么范围时将打印字符串“second”( )
A.x>0
B.x>-3
C.x<=-3
D.x<=0&x>-3
答案
参考答案:D
解析: 本题考查if-else语句的应用。从题中给出的代码段可以分析出来,当程序打印字符串“second”时,x的取值范围为(-3,0),即选择D。