41. 设有定义 int a = 12 ;则执行以下语句后,a 的值为。(选择1 项)
a *= 12;
A. 144
B. 12
C. 24
D. 0
42. 下面程序的输出结果是。(选择1 项)
public class ex2 {
public static void main(String[] args)
{
for(int cnt=0;cnt<10;cnt++)
{
if(cnt==5)
break;
System.out.print(cnt);
}
}
}
A. 0 1 2 3 4
B. 6 7 8 9
C. 0 1 2 3 4 6 7 8 9
D. 5
43. Applet 默认使用下列哪一个布局管理器?(选择1 项)
A. BorderLayout
B. FlowLayout
C. BoxLayout
D. GridLayout
44. 下面程序的输出结果是。(选择1 项)
public class ex2 {
public static void main(String[] args)
{
for(int cnt=0;cnt<10;cnt++)
{
if(cnt==5)
break;
System.out.print(cnt);
}
}
}
A. 0 1 2 3 4
B. 6 7 8 9
C. 0 1 2 3 4 6 7 8 9
D. 5
45. 在Java 语言中,在类SquareRoot 中定义了方法method A,其中包含语句:double
my_result=Math.sqrt(1000);需要导入()。(选择一项)
A. Java.lang.*
B. Java.Math.*
C. Java.util.Math.*;
D. 以上皆非
46. 下列整型的最终属性 i 的定义中,正确的是。(选择1 项)
A. final i;
B. static int i;
C. static final int i=234;
D. final float i=3.14f;
47. 欲构造ArrayList 类的一个实例,此类继承了List 接口,下列哪个方法是正确的 ?
A. ArrayList myList=new Object();
B. List myList=new ArrayList();
C. ArrayList myList=new List();
D. List myList=new List();
48. paint()方法使用哪种类型的参数?
A. Graphics
B. Graphics2D
C. String
D. Color
49. 指出正确的表达式
A. byte=128;
B. Boolean=null;
C. long l=0xfffL;
D. double=0.9239d;
50. 指出下列程序运行的结果
public class Example{
String str=new String("good");
char[]ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+" and ");
Sytem.out.print(ex.ch);
}
public void change(String str,char ch[]){
str="test ok";
ch[0]='g';
}
}
A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
51. 运行下列程序, 会产生什么结果
public class X extends Thread implements Runable{
public void run(){
System.out.println("this is run()");
}
public static void main(String args[])
{
Thread t=new Thread(new X());
t.start();
}
}
A. 第一行会产生编译错误
B. 第六行会产生编译错误
C. 第六行会产生运行错误
D. 程序会运行和启动
52. 要从文件" file.dat"文件中读出第10 个字节到变量C 中,下列哪个方法适合?
A. FileInputStream in=new FileInputStream("file.dat"); in.skip(9); int c=in.read();
B. FileInputStream in=new FileInputStream("file.dat"); in.skip(10); int c=in.read();
C. FileInputStream in=new FileInputStream("file.dat"); int c=in.read();
D. RandomAccessFile in=new RandomAccessFile("file.dat"); in.skip(9); int
c=in.readByte();
53. 容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改
变?
A. CardLayout
B. FlowLayout
C. BorderLayout
D. GridLayout
54. 给出下面代码:
public class Person{
static int arr[] = new int[10];
public static void main(String a[])
{
System.out.println(arr[1]);
}
}
那个语句是正确的?
A. 编译时将产生错误;
B. 编译时正确,运行时将产生错误;
C. 输出零;
D. 输出空。
55. 哪个关键字可以对对象加互斥锁?
A. transient
B. synchronized
C. serialize
D. static
56. 下列哪些语句关于内存回收的说明是正确的?
A. 程序员必须创建一个线程来释放内存;
B. 内存回收程序负责释放无用内存
C. 内存回收程序允许程序员直接释放内存
D. 内存回收程序可以在指定的时间释放内存对象
57. 下列代码哪几行会出错:
1) public void modify() {
2) int I, j, k;
3) I = 100;
4) while ( I > 0 ) {
5) j = I * 2;
6) System.out.println (" The value of j is " + j );
7) k = k + 1;
8) I--;
9) }
10) }
A. line 4
B. line 6
C. line 7
D. line 8
58. 执行下列代码后,哪个结论是正确的 String[] s=new String[10];
A. s[10] 为 "";
B. s[9] 为 null;
C. s[0] 为 未定义
D. s.length 为10
59. 2.下面的表达式哪个是正确的?
A. String s="你好";int i=3; s+=i;
B. String s="你好";int i=3; if(i==s){ s+=i};
C. String s="你好";int i=3; s=i+s;
D. String s="你好";int i=3; s=i+;
E. String s=null; int i=(s!=null)&&(s.length>0)?s.length():0;
60. 选出合理的标识符
A. _sys1_lll
B. 2mail
C. $change
D. class
61. 哪个布局管理器使用的是组件的最佳尺寸( preferred size)
A. FlowLayout
B. BorderLayout
C. GridLayout
D. CardLayout
E. GridBagLayout