计算机二级java语言概论第二章练习题及答案

考试站(www.examzz.com)   【考试站:中国教育考试第一门户】   2013年7月11日

  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


首页 1 2 3 尾页

相关文章