设为首页 加入收藏

TOP

2011年计算机二级Java阅读代码段章节练习题及答案
2014-11-07 12:45:08 来源: 作者: 【 】 浏览:32
Tags:2011年 计算机 二级 Java 阅读 代码 章节 习题 答案

  1 阅读下列代码段:


  Int i=3, j ;


  Outer : while (i>0)


  {


  J=3 ;


  Inner:while (j>0)


  {


  If (j<2) break inner;


  System.out.println(j+”and”+i) ;


  j-- ;


  }


  i -- ;


  }


  下列哪一项将不会被输出到屏幕上


  A ) 3and3 B) 3and2 C) 3and1 D)3and0


  2. 如果要抛出异常,应该采用的子句是----------


  A) catch B) throw C) try D) finally


  3.阅读下面代码段:


  Public class person


  {


  Int arr [ ]= new int [10];


  Public static vond main (string a[ ])


  {


  System.out.println(arr[1]);


  }


  }


  执行结果正确的说法是------------。


  A) 编译时将产生错误 B) 编译时正确,运行时将产生错误


  C) 输出零 D) 输出空


  4.阅读下面代码段:


  Public class Test


  {


  Public static void main (string args [ ])


  {


  Char ch ;


  Switch (ch)


  {


  Case ‘a’: system.out.print(“abc”);break;


  Case’b’: system.out.print(“ab”);


  Case’c’: system.out.print(“c”);break;


  Default: system.out.print(“abc”);


  }


  }


  }


  不输出”abc”的ch值是-----------。


  A)’a’ B) ‘b’ C) ‘c’ D) ‘d’


  5.和语句


  For (int x=0;x <15; x+=2) sum+=x+5;


  作用一样的语句是--------------。


  A) for (int x =5; x<20;x+=2)sum+=x;


  B) for(int x=5;x<20;x+=x-2)x+=2;


  C) for(int x=0;x<15;x+=2)sum+=x+3;x+=2;


  D) 上述全对  


  6. 阅读下列代码:


  Public class Test{


  Public static void mian ( String args[] ) {


  Float a=4.0f, b=6.0f, c=8.0f;


  String s=”10.0”;


  System.out.println(a+b+s+c);


  System.out.println();


  }


  }


  程序运行结果为________.


  A) absc B) 4.06.0101.08.0


  C) 10.010.08.0 D) 4.06.010.08.0


  7. 阅读下列代码:


  Public class Test{


  Public static void main ( String args[] ) {


  String s1= new String(“hello”);


  Stirng s2= new String(“hello”);


  Stirng s3= s1;


  System.out.println( s1 = =s2 );


  System.out.pirntln( s1 = = s3 );


  }


  }


  程序运行结果为_________.


  A) true,false B) true,true C) false,true D) false,false


  编辑推荐:


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2011年计算机二级Java数组章节练.. 下一篇2011年计算机二级Java对象、类章..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: