2011年计算机等级考试二级Java章节练习题第二套

开发 后端
51CTO整理“2011年计算机等级二级Java考前模拟题”,方便考生备考!

第二章 简单数据类型

  1、下列属于合法标识符的是__________。 答案:A

  A)_wind B)5tie C)+file D)room#

  2、下列数中,表示为八进制整数的是__________。 答案:B

  A)0xB8 B)0156 C)4096L D)‘\141’

  3、下列数中,表示为单精度浮点数的是__________。 答案:C

  A)0.652d B)3.14156D C)0.29874f D)0568

  4、作用域是整个类的变量属于__________。 答案:D

  A)局部变量 B)方法参数变量 C)异常参数变量 D)类变量

  5、用单引号括起来表示并占内存16为的数据类型是__________。 答案:C

  A)字节型 B)短整型 C)字符型 D)不尔型

  6、利用Java编译器改正下列程序的错:

  public class Exercise1{

  public static void main (String[] args){

  int i = 97;

  char j = i;

  System.out.println(“j = “+j);

  }

  } 答案:D

  A)将 int = 97;改为 int i = ‘97’ B) 将 int = 97;改为 float i = 97

  C)将 int = 97;改为 long i = 97 D)将 int = 97;改为char i= 97

  7、改正程序下划线处错误:

  class Variable{

  int x = 0,y = 0, z= 0;//类变量

  void init (int x,int y){

  x = x;

  y = y;

  int z = 5; //局部变量

  System.out.println(“******在初始化中*******”);

  System.out.println(“x = “ +x+” y = “+y+” z = “+z);

  }

  } 答案:B

  A) int x = x; int y = y; B)this.x = x; this.y = y;

  C)v.x = x; v.y = y ; D)this.v.x = x ; this.v.y = y;

  8、改正下列程序的错误:

  public class Exercise3{

  public static void main (String[] args){

  int i = 1000000;

  short j;

  j = (short) i;

  System.out.println(“i = “+i);

  System.out.println(“j = “+j);

  }

  }

  要求获得以下运行结果:

  i = 1000000

  j = 16960 答案:B

  A)将short j; j = (short) i;改为short j ; j = i*100;

  B)将short j; j = (short) i;改为long j ; j = i*100;

  C)short j; j = (short) i;改为byte j ; j = i*100;

  D)short j; j = (short) i;改为char j ; j = i*100;

转回2011年9月全国计算机等考专题

责任编辑:艾婧 来源: 考试吧
相关推荐

2011-09-01 15:37:43

Java

2011-08-31 16:19:48

Java

2011-08-31 16:11:09

Java

2011-09-01 15:59:03

Access

2011-08-31 16:44:37

Java

2011-08-31 16:40:36

等级考试

2009-01-08 21:33:34

2009计算机等级考试二级

2011-08-31 16:23:10

Access

2011-09-17 19:49:05

计算机等级考试

2011-09-17 20:12:24

计算机等级考试

2011-01-06 11:03:15

三级PC技

2011-01-13 10:45:11

三级PC技术

2010-12-28 10:58:34

PC技术

2011-01-24 10:28:03

三级PC技术

2010-12-15 11:29:43

PC技术

2011-01-20 10:34:26

三级PC技术

2011-01-27 10:52:53

三级PC技术

2010-12-23 11:23:25

PC技术

2011-03-04 10:44:12

三级PC技术

2010-12-15 11:38:06

PC技术
点赞
收藏

51CTO技术栈公众号