一、选择题(2分/题)
1、根据这个类选择所有正确的内部类:(多选)
class A {
protected int I;
A(int i){
This.i=I;
}
}
asd
2、下列所给出的声明中,什么会写入标准输出中?(单选)
System.out.println(4|7)
a.4 b.5 c.6 d.7 e.0
3、下列有关方法notify()(用于和wait()连接)的正确描述是:(单选)
a. if there is more than one thead waiting on a condition,only the thread that has been waiting the longest is notified.
b. if there is more than one thead 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 notstrictly necessary to own the lock for the object you invoke notify() for.
e. Notify() should only be invoked form within a while loop.
4、给出下列类的定义,如没有其他实例的引用,method2()能直接访问到:(多选)
class A {
public int x;
private int y;
class B {
protected void method1(){
}
class C {
privated void method2()
{
}
}
}
}
class d axtends 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个可获取的变量)
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()方法的声明是错误的?(多选)
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,你可以添加哪一个执行接口?(多选)
a. ActionListener
b. FocusListener
c. MouseMotionListener
d. WindowListener
e. ContainerListener
8、当你试着编译和运行下面的程序时,结果怎样?(单选)
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.试分析以下两行代码:(多选)
float f=3.2;
int I=f;
a. This code would not compile
b. This code would compile and iwould be set to 3.
c. The second 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
10.在下面init()方法给出的applet中,用户接口将出现什么情况 (单选)
public void init(){
setlayout(new BorderLayout())
add(new Button(“hello”))
}
a. Nothing will appear in the applet
b. Abutton will appear in the applet set int the exact center.
c. Abutton will appear in the applet along the top and centered horizontally.
d. Abutton will appear in the top left corner.
11.如果你在JDK1.2X下想要用值将关键字联系起来,则以下哪个类位首选 (多选)
a. Dictionary
b. HashTable
c. Properties
d. HashMap
e. TreeMap
12.定义一个名为key的无继承类正确方法是 (单选)
a. class Key{}
b. abstract final class Key{}
c. native class Key{}
d. class Key{
final
}
e. finai class Key{}
13.下列哪一个能代表一个octalnumber (单选)
a. 0×1