如下程序执行后,字符串s的值应是______。 public class Test24 { public static void main (String args[ ]) { String greets="Hello"; String s=greets.substring(0,3); System.out.println(s); } }
A. ello
B. Hel
C. Hello
D. el
查看答案
请阅读如下程序。 public class ExampleStringBuffer { public static void main (String[] args) { StringBuffer sb=new StringBuffer ("test"); System.out.println ("buffer= "+sb); System.out.println ("length= "+sb.length ()); } } 程序运行结果中在“length=”后输出的值是______。
A. 10
B. 4
C. 20
D. 30
循环语句中经常加入continue语句完成特定的功能,则执行continue语句后______。
A. 跳过循环体下面的语句,继续下次循环
B. 再次循环前不需要判断终止条件
C. 跳出循环
D. 以上说法都不正确
下列程序的执行结果是______。 public class Test { public static void main(String[] args) { int[] x={0, i,2,3}; for(int i=0;i<3;i+=2) { try{ System.out.println(x[i+2]/x[i]+x[i+1]); }catch(ArithmeticException e) { System.out.println("error1"); }catch(Exception e) { System.out.println ("error2"); } } } }
A. error1
B. error2
C. error1 error2
D. 2 error2
在多分支语句switch(表达式){}中,表达式不可以返回______。
A. 短整型
B. 字符型
C. 接口型
D. 整型