JAVA开发工程师面试题《一》
备注•• 请不要在试卷上打草稿!
请将答案填在答题纸上,100分钟内完成
1.根据这个类选择所有正确的内部类:(多选)ABC class A {
protected int i;
A(int i){
this .i=i;
}
wednesday是什么意思
a. | b. | c. | d. | e. |
class B{ | class B extends A { | class B{ | class B{ | class A { |
} | } | B(){ | class | } |
| | | A{ | |
| | System.out.println(Hi = | } | cscd |
| | n+i); I } | } | |
| | | | |
螲蟷
2.下列所给出的声明中,什么会写入标准输出中?(单选)D
System.out.prindn(4 | 7)?
a.4 b. 5 c. 6 d. 7 e. 0
3.下列有关方法notify()(用于和wait()连接)的正确描述是:(单选)A
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()能直接访问到:(多选)A
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 Dcretary怎么读
5.你有一个用ISO 8859—8定义的8位字符串文档,当你要在文本域中写一个显示该文档的应用,而局部编码己
经设置成ISO 8859—8时,你如何写一段代码来读取该文档的第一行?(你有3个可获取的变量)
a.InputStreamReader reader = new lnputStreamReader(stream,’’8859-8’’);
BufferedReader buffer = new BufferedReader(reader);
s = adLine();
b.InputStreamReader reader = new InputStreamReader(stream);
BufferedReader buffer = new BufferedReader(reader);
s = adLine();滞留是什么意思
c.InputStreamReader reader = new lnputStreamReader(myfile,"8859-8’’);
BufferedReader buffer = new BufferedReader(reader);
s = adLine();
d.InputStreamReader reader = new InputStreamReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = adLine();
全国英语四级考试官网
e.FileReader reader = new FileReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = adLine();
6.哪一个对单机程序中的main()方法的声明是错误的?(多选)DE
a.public static void main()
anecdoteb.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,你可以添加哪一个执行接口?(多选)AB
a.ActionListener
b.FocusListener
c.MouMotionListener
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);
}
}
a.This code will not compile.
b.This code compiles but throws an exception at runtime.
廉颇蔺相如列传知识点c.This code runs but nothing appears in the standard output.
d.This code runs and ’’constructor” in the standard output.
e.This code runs and writes ..null.’ in the standard output.
9.试分析以下两行代码:(多选)ACD
float f = 3.2;
int i = f;
a.This code would not compile.
b.This code would compile and i would be t to 3.
c.The cond line would compile if it were written instead as: int i = (byte)if;
d.The first line would compile if it were written instead as: float f = 3.2F;
在下面init()方法给出的applet中,用户接口将出现什么情况?(单选)C
tLayout(new BorderLayout()); add (new Button(”hello’’));
}
滑铁卢大学排名
a.Nothing will appear in the applet.
b.A button will appear in the applet t int the exact center.
c.A button will appear in the applet along the top and centered horizontally.
d.A button will appear in the top left corner.
10.如果你在JDK1.2下想要用值将关键字联系起来,则以下哪个类位首选?(多选)BD
a.Dictionary
b.HashTable
c.Properties
d.HashMap
e.TreeMap
11.定义一个名为Key的无继承类正确方法是?(单选)E
a.class Key{}
b.abstract final class Key{}
c.native class Key{}
d.class Key{ final;
}
e.final class Key{}
12-下列哪一个能代表一个octal number?(单选)D
a.0x12
b.320
c.032
d.(octal)2
e.12
13.当你运行Tested类时,将得到什么标准输出结果?(单选)E
class Tester2{ int var;
Tester(double var){ this.var = (int)var;
}
Tester(int var){ this("hello");
}
Tester(String s){ this();
System.out.println(s);
}
Tester(){纸牌屋第三季
System.out-printlnCgood-bye11);
}
public static void main(String[] args){
Tester t = new Tester(5);
}
}
a.nothing
b."hello"
c.5
d."hello" following by "good-bye"
e."good-bye" followed by "hello"
14.根据提供如下代码,如果方法tryThis()发生一个NumberFormatException,将得到什么标准结果?(单选)
try{ B
tryThis();
return;
}catch(IOException x1){
System.out.println(nexception 1 ••); return;
}catch(Exception x2){
System.out.println(’’exception 2n); return;
}finally{
System.out.printlnff inally");
}
a.Nothing
b."exception 1" followed by "finally"