39:要建立数据源,首先要建立Access数据库。( 2 分) A:正确 B:错误
答案:B
40:Java不提供goto语句,所以goto也就不再作为关键字( 2 分) A:正确 B:错误
答案:B
41:一个异常处理中 finally语句块只能有一个或者可以没有。( 2 分) A:正确 B:错误
答案:A
42:一个类可以生成多个对象,并且这些对象都具有相同的属性。( 2 分) A:正确 B:错误
答案:A
43:JavaBeans是轻量级的构件,EJB是重量级的构件。( 2 分) A:正确 B:错误
答案:A
44:有的类定义时可以不定义构造函数,所以构造函数不是必需的。( 3 分) A:正确 B:错误
答案:B
45:一个非抽象类如果实现了某个接口,那么它必须覆盖该接口中的所有方法。( 3 分) A:正确 B:错误 答案:A
三、程序阅读题
1、以下程序的输出结果为_ Peter is 17 years old!___。
public class Person { }
public static void main(String[] args) { }
Person c = new Person(\, 17);
System.out.println(c.name + \ + c.age + \); public Person(String name, int age) { }
this.name = name; this.age = age; String name; int age;
2、以下程序的输出结果为__课程号:101 课程名:ASP 学分:3___。
public class Course {
public void printCourseInfo() {
System.out.println(\课程号:\ + cNumber + \课程名:\ + cName + \学public Course(String number, String name, int unit) { }
cNumber = number; cName = name; cUnit = unit; private String cNumber; private String cName; private int cUnit;
分:\ + cUnit); } }
class CourseTest { }
public static void main(String[] args) { }
Course c;
c = new Course(\, \, 3); c.printCourseInfo();
3、以下程序的输出结果为__汤姆猫体重:20.0斤___。
public class Tom { }
public static void main(String[] args) { }
Tom.name = \汤姆猫\; Tom cat = new Tom(); cat.setWeight(20); cat.out(); private void out() {
System.out.println(name + \体重:\ + weight + \斤\); }
public void setWeight(float weight) { }
this.weight = weight; private float weight; private static String name;
4、以下程序的输出结果_姓名:Tom 年龄:15 家庭住址:金水区 电话:66123456 学校:九中_。
public class Father { }
class Son extends Father {
void outOther() {
System.out.print(\家庭住址:\ + address); System.out.print(\电话:\ + tel); }
void out() {
System.out.print(\姓名:\ + name); System.out.print(\年龄:\ + age); }
public Father(String name, int age) { }
this.name = name; this.age = age;
String name, address, tel; int age;
}
String school;
public Son(String name, int age) { }
void out() {
super.out(); super.outOther(); super(name, age);
System.out.println(\学校:\ + school); }
public static void main(String args[]) { }
Son son = new Son(\, 15); son.address = \金水区\; son.school = \九中\; son.tel = \; son.out();
5、下列程序的运行结果是__12345____。
public class MyClass { }
public static void main(String[] args) { }
MyClass my = new MyClass(); my.out(); void out() { }
for (int j = 0; j < a.length; j++)
System.out.print(a[j] + \);
int a[] = { 1, 2, 3, 4, 5 };
1、 import java.io.*;
public class abc {
public static void main(String args [ ]) {
AB s = new AB(\VA.\
System.out.println(s.toString( )); } } class AB { String s1; String s2;
public AB(String str1, String str2) {
s1 = str1; s2 = str2; }
public String toString( ) {
return s1+s2; } }
运行结果:Hello! I love JAVA.
2、 import java.io.* ; public class abc {
public static void main(String args[ ]) { int i, s = 0 ;
int a[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 }; for ( i = 0 ; i < a.length ; i ++ ) if ( a[i]%3 = = 0 ) s += a[i] ; System.out.println(\ } }
运行结果:s = 180
3、import java.io.* ; public class abc {