JAVA开发工程师考试题

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

全国1+N 复合型技能人才培训JAVA 开发工程师考试试卷

1.

int index=1;

int foo[]=new int[3]; int bar=foo[index]; int baz=bar+index;

经过以上代码后,baz 的值是多少?( b )

A . baz 值为 0

B . baz 值为1

C . baz 值为2

D . 程序运行时抛出异常

E . 代码不能编译

2.

Public class Test{

Public static void add3(Integer i){

int val=i.intvalue(); val+=3;

i=new Integer(val); }

Public static void main(String args[]){

Integer i=new Integer(0);

add3(i);

System.out.println(i.intvalue()); }

}

以上代码执行结果是什么?( b )

A . 编译错误

B . 打印"0"

C . 打印"3"

D . 编译成功但运行时有第3行出现异常 3.

class EnclosingOne{

public class InsideOne{} }

Public class InnerTest{

Public static void main(String args[]){ EnclosingOne eo=new EnclosingOne(); //在这插入代码

} }

应将哪行代码插入代码块中?( e )

A . InsideOne ei=eo.new InsideOne();

B . eo.InsideOne ei=eo.new InsideOne();

C . InsideOne ei=EnclosingOne.new InsideOne();

D . InsideOne ei=eo.new InsideOne();

E . EnclosingOne.InsideOne ei=eo.new InsideOne(); 4. 下面哪个是"is a"的关系?(b )

A . Public interface Color{}

public class Shape{private Color color;} B . interface Component{}

class Container implements Component{ private Component[] children; }

C . public class Species{}

考试地点:

考生姓名: 考生性别: 考生年龄:

证件类型: 证件号码:

一、 选择题(本大题共40小题,每小题1分,共40分)

在每小题列出的备选项中只有一个是符合题目要求的,请将其代

码填写在题后的括号内。错选、多选或未选均无分。

publiclass Animal{private Species species;}

5.

public class SychTest{

private int x;

private int y;

public voisetX(int i){ x=i;}

public voisetY(int i){y=i;}

public synchronize void setXY(int i){

setX(i);

setY(i);

}

Public synchronizeboolean check(){

return x!=y;

}

}

在什么条件下,在其它类中调用check()返回true? ( c )

A.check() 永远不返回 true

B.当setXY 被多个线程调用时check() 返回true

C.当多个线程分别调用setX和setY时check() 返回true

D.只有SychTest被改写为x和y可以分别赋值时check() 才可能返回 true 6.

class implements Runnable{

int i;

public void run(){

try{

Thread.sleep(5000);

i=10;

}

catch(InterruptException e){}

}

Public static void main(String[] args){

try{

a=new A();

Thread t=new Thread(a);

t.start();

14)

int j=i;

16)

}catch(Exception e){}

}

}

在第14行加上哪些代码才能保证在第16行时j=10? ( c )

A.wait();

B.t.wait();

C.t.join();

D.t.yield();

E.t.notify();

7.下面的哪个方法能够识别出是哪个组件产生了ActionEvent事件?( c )

A.getTarget();

B.getClass();

C.getSource();

D.getActionCommand();

8.

import java.awt.*;

public class X extends Frame{

public static void main(String[] args){

X x=new X();

x.pack();

x.setVisible(true);

}

Public X(){

setLayout(new GridLayout(2,2));

Panel p1=new Panel();

add(p1);

Button b1=new Button("One");

p1.add(b1);

Panel p2=new Panel();

add(p2);

Button b2=new Button("Two");

p2.add(b2);

Button b3=new Button("Three");

相关文档
最新文档