甲骨文大赛校内测试题(含答案)讲述.doc
文本预览下载声明
甲骨文程序设计大赛试题
姓名: 专业班级:
一、单项选择题:
1. MapString, ? extends CollectionIntegermap;
请问以下哪个赋值语句会出错?()
B、map=new HashMapString ,ListInteger( );
C、map=new HashMapString, LinkedListInteger( );
D、map=new LinkedHashMapObject , List Integer( );
2.代码片段:
public class Certkiller3 implements Runnable {
public void run( ) {
System.out.print(running);
}
public static void main(String[ ] args) {
Thread t = new Thread(new Certkiller3( ));
t.run( );
t.run( );
t.start( );
}
}
结果()
A、编译出错B、运行时异常C、代码正常执行输出:
D、代码正常执行输出:running
E、代码正常执行输出:runningrunnng
3. 代码片段:
public class Test {
private int a;
public int b;
protected int c;
int d;
public static void main(String[ ] args) {
Test test = new Test( );
int a = test.a++;
int b = test.b--;
int c = test.c++;
int d = test.d--;
System.out.println(a + - + b + - + c + - + d);
}
}
下列哪个说法是正确的?(C)
A、编译错误,因为变量a,b,c和d没有被初始化 B、编译错误,因为变量a无法被访问
C、编译成功并输出0–0–0–0 D、编译成功并输出1 - - 1 – 1 - - 1
4. 代码片段1:
public class ComplexCalc {
public int value;
public void calc( ) { value += 5; }
}
代码片段2:
public class MoreComplexCalc extends ComplexCalc {
public void calc( ) { value -= 2; }
public void calc(int multi) {
calc( );
super.calc( );
value *= multi;
}
public static void main(String[ ] args){
MoreComplexCalc calc = new MoreComplexCalc( );
calc.calc(3);
System.out.println(Oh it is: + calc.value);
}
}
请问编译运行结果是 ?( A)
A、Oh it is: 9 B、编译出错 C、Oh it is: 15 D、Oh it is: -6
E、代码正常执行但没有输出 F、运行时抛出异常
G.、Oh it is: 6 H、Oh it is: -15
5. 代码片段:
void waitForSignal( ){
Object obj=new Object( );
synchronized(Thread.currentThread( )){
obj.wait( );
obj.notify( );
}
}
以下哪个描述是正确的?()ontestKiller=null;
/*在这里补充代码*/
以下哪一项的代码是告诉虚拟机尽最大的能力去回收contestKiller这个对象所占用的内存?()public void aSafeMethod(Object value){
//在这里检查方法的参数
//这里省去其他的代码
Sytem.out.println(value.toString
显示全部