JAVA面试题二

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

JAVA开发工程师面试题(一)

备注:请将答案填在答题纸上,100分钟内完成

1.根据这个类选择所有正确的内部类:(多选ac)

class A {

protected int i;

A(int i){

this .i=i;

}

}

2.下列所给出的声明中,什么会写入标准输出中?(单选d)

System.out.println(4 | 7)?

a. 4

b. 5

c. 6

d. 7

e. 0

3.下列有关方法notify()(用于和wait()连接)的正确描述是:(单选c)

a. if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified.

b. if there is more than one thread waiting on a condition, there is no way to predict which thread will be notified.

c. Notify () is defined in the Thread class.

d. It is not strictly necessary to own the lock for the object you invoke notify () for.

e. Notify () should only be invoked from within a while loop.

4.给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:(多选abc)

class A{

public int x;

private int y;

class B{

protected void method1(){

}

class C{

private void method2(){

}

}

}

}

class d extends A{

public float z;

}

a. The variable x defined in A

b. The variable y defined in A

c. method () defined in B

d. The variable z defined in D

5.你有一个用ISO 8859-8定义的8位字符串文档,当你要在文本域中写一个显示该文档的应用,而局部编

码已经设置成ISO 8859-8时,你如何写一段代码来读取该文档的第一行?(你有3个可获取的变量c)a. InputStreamReader reader = new InputStreamReader(stream,"8859-8");

BufferedReader buffer = new BufferedReader(reader);

s = buffer.readLine();

b. InputStreamReader reader = new InputStreamReader(stream);

BufferedReader buffer = new BufferedReader(reader);

s = buffer.readLine();

c.InputStreamReader reader = new InputStreamReader(myfile,"8859-8");

BufferedReader buffer = new BufferedReader(reader);

s = buffer.readLine();

d.InputStreamReader reader = new InputStreamReader(myfile);

BufferedReader buffer = new BufferedReader(reader);

s = buffer.readLine();

e.FileReader reader = new FileReader(myfile);

BufferedReader buffer = new BufferedReader(reader);

s = buffer.readLine();

6.哪一个对单机程序中的main()方法的声明是错误的?(多选cd)

a. public static void main()

b. public static void main(String[] string)

c. public static void main(string args)

d. static public int main(String[] args)

e.static void main(String[] args)

7.作为文本框对象的listeners,你可以添加哪一个执行接口?(多选acd)

a. ActionListener

b. FocusListener

c. MouseMotionListener

d. WindowListener

e. ContainerListener

8.当你试着编译和运行下面的程序时,结果怎样?(单选e)

class MyTest{

String s;

public static void main(String[] args){

MyTest m = new MyTest();

m.go();

}

void MyTest(){

s = "constructor";

}

void go(){

System.out.println(s);

}

}

相关文档
最新文档