姓名: 联系方式: 考试开始时间: A. 编译时错误
B. 编译成功,并打印出\C. 编译成功,并打印出\ D. 编译成功,并打印出\
15.在什么情况下类获得默认的构造方法:B A.类被定义时
B.类中没有定义任何构造方法时 C.在类中至少定义了一个构造方法时
16.listener(监听器)方法的正确的访问修饰符是什么?A A.public B.static C.private D.protected
E.Default(即默认为空)
17. 假定有一个包含引起异常(不是一个RuntimeException)的代码的方法,用什么方式告诉方法的调用者要捕获该异常:B A.throw Exception B.throws Exception C.new Exception D.不用特别指定
18.下面的代码能打印出的结果是:A,B public class MyFor{
public static void main(String argv[]){ int i; int j; outer:
for (i=1;i <3;i++) inner:
for(j=1; j<3; j++) { if (j==2)
continue outer;
System.out.println(\} } }
A.Value for i=1 value for j=1 B. Value for i=2 value for j=1 C. Value for i=2 value for j=2 D. Value for i=3 value for j=1
5
姓名: 联系方式: 考试开始时间: 19.那个代码能够添加在//mothod here地方,并能正确执行?B,C class Base{
public void amethod(int i) { } }
public class Scope extends Base{
public static void main(String argv[]){ }
//Method Here }
A. void amethod(int i) throws Exception {} B. void amethod(long i)throws Exception {} C. void amethod(long i){}
D. public void amethod(int i) throws Exception {}
20.运行下面代码能够得出的结果?B String s=new String(\int iBegin=1; char iEnd=3;
System.out.println(s.substring(iBegin,iEnd)); A.Bic B. ic C. icy
D. error: no method matching substring(int,char)
21.下面定义的变量能执行那些操作?A String s1=new String(\String s2=new String(\String s3=new String();
A. s3=s1 + s2; B.s3=s1-s2; C.s3=s1 & s2; E. s3=s1 && s2
22. System.out.println(4 | 3);
能打印出什么结果?D A 6 B 0 C 1 D 7
23. 传递4,0来运行下列代码中的方法divide(int a, int b),结果是:A public void divide(int a, int b) {
try {
int c = a / b;
6
姓名: 联系方式: 考试开始时间: } catch (Exception e) {
System.out.print(\} finally {
System.out.println(\
}
A.打印输出: Exception Finally B.打印输出: Finally C.打印输出: Exception D.没有任何输出
24. 对public void add(int a) {…}方法的重写方法:A A.必须返回void B.必须返回int
C.可以返回任何需要的类型
25. 对public void add(int a) {…}方法的重载方法应返回:C A.void B.int
C.任何类型
26. 下列类分别在不同的文件中定义:C
class Vehicle {
public void drive() {
System.out.println(\} }
class Car extends Vehicle {
public void drive() {
System.out.println(\} }
public class Test {
public static void main (String args []) {
Vehicle v; Car c;
v = new Vehicle(); c = new Car(); v.drive(); c.drive(); v = c; v.drive(); } }
7
姓名: 联系方式: 考试开始时间: 编译和执行类Test后,结果是: A.在语句v= c;处产生编译时错误 B.在语句v= c;处产生运行时错误 C.输出: Vehicle: drive Car: drive Car: drive D.输出:
Vehicle: drive Car: drive Vehicle: drive
27. 在子类构造方法内的什么位置可以对超类的构造方法(super())进行调用:B A.子类构造方法的任何地方 B.子类构造方法的第一条语句处 C.子类构造方法的最后一条语句处 D.不能对超类的构造方法进行调用
28. 下列代码中有明显的语法错误的语句是:C
1. public class Test {
2. public static void main (String args []) {
3. Employee e = new Employee(\ 4. e.calculatePay();
5. System.out.println(e.printDetails()); 6. e = Null;
7. e = new Employee(\ 8. e.calculatePay();
9. System.out.println(e.printDetails()); 10. }
}
A.Line 10 B.Line 11 C.Line 6 D.Line 8
29. 选择可以建立线程的接口:A A.Runnable B.Run
C.少数用于管理的系统部件
D.Thread E.Executable
30. 选择正确生成text field的代码,此text field最多能够显示10个字符(假定其字体有固定大小)并最初显示“hello”串:A
8
相关推荐: