《JAVA语言程序设计》期末考试试题及答案3(应考必备题库)(1)

时间:2025-04-16

《JAVA语言程序设计》期末考试试题及答案3(应考

必备题库)

一、单项选择题

1、如下哪个是Java中的标识符()

A、public

2、如下哪个是Java中的标识符( )

A、fieldname B、super

3、已知如下定义:String s = "story"; 下面哪个语句不是合法的( )

A、s += "books";

4、如下哪个是Java中有效的关键字()

A、name

5、下面的代码段执行之后count的值是什么( )

int count = 1; for (int i = 1; i <= 5; i++) { } System.out.println(count); count += i; B、super C、3number D、width C、3number D、#number B、s = s + 100; D、String t = s + “abc”; C、int len = s.length; B、hello C、false D、good

A、5

B、1 C、15 D、16

6、定义一个类,必须使用的关键字是( )

A、public

7、定义一个接口必须使用的关键字是( )

A、public

8、如果容器组件p的布局是BorderLayout,则在p的下边中添加一个按钮b,应该使用的语句是( )

A、p.add(b); B、p.add(b,"North"); D、b.add(p,"North"); C、p.add(b,"South"); B、class C、interface D、static B、class C、interface D、static

9、声明并创建一个按钮对象b,应该使用的语句是( )

A、Button b=new Button(); B、button b=new button();

C、Button b=new b(); D、b.setLabel(“确定”);

10、Frame对象默认的布局管理器是( )

A、FlowLayout

C、CardLayout

11、下列哪一个import命令可以使我们在程序中创建输入/输出流对象()

A、import java.sql.*;

C、import java.io.*;

12、下面哪一个import命令可以为我们提供编写网络应用程序的类()

A、import java.sql.*;

C、import java.io.*;

13、如果需要从文件中读取数据,则可以在程序中创建哪一个类的对象()

A、FileInputStream

二、填空题

1、如果将类MyClass声明为public

2、Java程序中的单行注释符是( ),多行注释符是( )。

3、Java中布尔类型的常量有两种,它们是( )和( )。

4、Java中用于定义小数的关键字有两个:( ) 和 ( ),后者精度高于前者。

5、Java中用于两个数相等比较的运算符是:( ),用于不相等比较的运算符是( )。

6、在Java中定义一个字符串类型的变量str,定义一个具有10个元素的整型数组a的语句是:( ) 。

7、导入mypackage。

8、当声明一个数组int arr[] = new int[5]; 时,这代表这个数组所保存的变量类型 B、FileOutputStream D、FileWriter C、DataOutputStream B、import java.util.*; D、import http://www.77cn.com.cn.*; B、import java.util.*; D、import http://www.77cn.com.cn.*; B、BorderLayout D、null

是(),数组名是( ),数组的大小为( ),数组元素下标的使用范围是( )。

9、假设x=13,y=4,则表达式x%y != 0的值是( ),其数据类型是( )。

10、异常处理是由( )、( )和finally块三个关键所组成的程序块。

11、以下程序段的输出结果是( )

int x = 5, y = 6, z = 4; if (x + y > z && x + z > y && z + y > x) System.out.println("三角形"); else System.out.println("不是三角形");

12

int a[] = { 2, 3, 4, 5, 6 }; for (int i = a.length - 1; i >= 0; i--) System.out.print(a[i] + "");

三、程序阅读题

1、以下程序的输出结果为_ ___。

public class Person {

} public static void main(String[] args) { } Person c = new Person("Peter", 17); System.out.println(http://www.77cn.com.cn + " is " + c.age + " years old!"); public Person(String name, int age) { } http://www.77cn.com.cn = name; this.age = age; String name; int age;

2、以下程序的输出结果为_ ___。

public class Course {

private String cNumber; private String cName; private int cUnit;

public void printCourseInfo() { System.out.println("课程号:" + cNumber + " 课程名:" + cName + " 学public Course(String number, String name, int unit) { } cNumber = number; cName = name; cUnit = unit; 分:" + cUnit);

}

}

class CourseTest {

} public static void main(String[] args) { } Course c; c = new Course("101", "ASP", 3); c.printCourseInfo();

3、以下程序的输出结果为__ ___。

public class Tom {

} public static void main(String[] args) { } http://www.77cn.com.cn = "汤姆猫"; 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、以下程序的输出结果_ _。

public class Father {

}

class Son extends Father {

} public static void main(String args[]) { } Son son = new Son("Tom", 15); son.address = "金水区"; son.school = "九中"; son.tel = "66123456"; son.out(); void out() { super.out(); super.outOther(); public Son(String name, int age) { } super(name, age); String school; void outOther() { System.out.print(" 家庭住址:" + address); System.out.print(" 电话:" + tel); } void out() { System.ou …… 此处隐藏:2256字,全部文档内容请下载后查看。喜欢就下载吧 ……

《JAVA语言程序设计》期末考试试题及答案3(应考必备题库)(1).doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219