Java程序设计语言能力考试(试卷).docx
文本预览下载声明
PAGE \* MERGEFORMAT 7
Java程序设计语言
技术能力考试
课程名称java程序设计语言2011 考试时间 60分钟
考试方式(闭)卷 (共 7 页)
(本试卷满分100分,60分合格,答案请写在答题卡上)一、选择题(含单选题和多选题,每题3分,共60分)
在每小题列出的四个备选项中只有1个或多个是符合题目要求的,多选题已标出选择几个正确答案,请将其答案填写在答题卡上,错选或未选均无分。
Given:
public class Outer{
public void someOuterMethod() {
// Line 3
}
public class Inner{}
public static void main( String[]argv ) {
Outer o = new Outer();
// Line 8
}
}Which instantiates an instance of Inner?
A. new Inner(); // At line 3
B. new Inner(); // At line 8
C. new o.Inner(); // At line 8
D. new Outer.Inner(); // At line 8
Given:
int x = 1, y =6;
while (y--) {
x++;
}
System.out.println(“x =” + x + “y =” +y); What is the result?
A. x = 6 y = 0
B. x = 7 y = 0
C. x = 6 y = -1
D. x = 7 y = -1
E. Compilation fails.
Given:
for (int i =0; i 4; i +=2) {
System.out.print(i + “ ”);
}
System.out.println(i); What is the result?
A. 0 2 4
B. 0 2 4 5
C. 0 1 2 3 4
D. Compilation fails.
E. An exception is thrown at runtime.
Given:
public class Exception Test {
class TestException extends Exception {}
public void runTest() throws TestException {}
public void test() /* Point X */ {
runTest();
}
}At Point X on line 4, which code is necessary to make the code compile?
A. No code is necessary.
B. throws Exception
C. catch (Exception e)
D. throws RuntimeException
E. catch ( TestException e)
Given:
try {
int x = 0;
int y = 5 / x;
} catch (Exception e) {
System.out.println(“Exception”);
} catch (ArithmeticException ae) {
System.out.println(“Arithmetic Exception”);
}
System.out.println(“finished”); What is the result?
A. finished
B. Exception
C. Compilation fails.
D. Arithmetic Exception
Given:
abstract class AbstractIt {
abstract float getFloat();
}
public class AbstractTest extends AbstractIt {
private float f1 = 1.0f;
private float getFloat() { return f1; }
}What is the result?
A. Compilation succeed
显示全部