scjp试题解析四十

qq:2535279


 Given the following code:
  if (x>0) { System.out.println("first"); }
  else if (x>-3) { System.out.println("second"); }
  else { System.out.println("third"); }
  Which range of x value would print the string "second"?
  A. x > 0
  B. x > -3
  C. x <= -3
  D. x <= 0 & x > -3
  翻译
  给出下面的代码:
  …
  x的取值在什么范围内时将打印字符串"second"。
  答案 D     www.javaedu.com.cn
  解析 x>0时打印"first",x>-3&&x<=0时打印"second",x<=-3时打印"third"。这个题目没有什么难的,只要理解if语句的语法就可以了。