计算机06期末考试题《Java程序设计》A卷2
时间:2026-01-19
时间:2026-01-19
《 Java程序设计》课程试题参考答案及答案
课程名称: 课程名称 Java 程序设计 适用专业年级 : 计算机 06 级学号题号 题分 得分 一 20 二 15 三 16 四 14 五 20 六 15
(A 卷
闭卷) 闭卷)
考试时间 100 分钟总分 100 统分人 签名
姓名
考生注意事项:1、本试卷共 3 页,试卷如有缺页或破损,请立即举手报告以便更换。 2、考试结束后,考生不得将试卷、答题纸和草稿纸带出考场。(答案请写在 密封线内和纸卷正面,否则不记分)
湖南工业大学考试试卷纸
班级 计算机 06-
一. Choose the best answer from the choices (20 Points, 2 Points each)1.Java language is ( ). A. Problem-oriented, interpreted, advanced language B. Machine-oriented, low-level language C. Procedure-oriented, complied, advanced language D. Object-oriented, interpreted, advanced language 2. The statement ‘for(;;)’ is ( ). A. loop structure. B. branch structure C. sequence structure d. unknown 3. Which of the viewpoints listed below is right ? A.The identifiers of Java are case-sensitive. B.The name of source file may be different from the one of public class. C.The extension of Java source file is ‘.jar’. D.The number of public class in source file is not limited 4. Which of the identifiers listed below is legal in Java ? A. +static B.5books C._cat D.-3.14159 5. In Java, which of the packages listed below is loaded by complier and not imported in program? A.java.applet B.java.awt C.java.util http://www.77cn.com.cnng 6. When reading char file ‘Employee.dat’, which of the classes listed below does use this file name as parameter? A.BufferReader B.DataInputStream C.DataOutoutStream D.FileInputStream 7. In Java, the way that implements the effect of multi-inheritance is ( ). A.internal class B.adapter C.interface D.synchronization 8. Which of the methods listed below can be used to create a new thread ? A.implement http://www.77cn.com.cnng.Runnable interface and rewrite start( ) method. B.extend http://www.77cn.com.cnng.Thread class and rewrite run( ) method. C.implement http://www.77cn.com.cnng.Runnable interface and rewrite runnable( ) method. D.extend http://www.77cn.com.cnng.Thread class and rewrite start( ) method..
9. Which of states about Java Application and Applet listed below is right ? A.both of them include main( ) method. B.both of them are executed with “appletviewer” command. C.both of them are complied with “javac” command. D.both of them are inserted into HTML file to be executed. 10. In following codes, there is a compiling error. 1)public class Test{ 2) int m,n; 3) public Test() {} 4) public Test(int a) {m=a;} 5) public static void main(String args[]){ 6) Test t1,t2; 7) int j, k; 8) j=0;k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12) } A.3 row B.5 row C.6 row
D.10 row
二. True or False(15 Points, 1 Point each)1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. In Java, two operators should be integer in ‘%’ operation. All kinds
of data types have fixed memory length in Java, they are software and hardware independent. If you implement an interface, all methods in it should be implemented. There is only a constructed function in a Java class. Java can be used to design multimedia and network programs. The private members of class can not be inherited. A Java class does not exist two member functions with the same name. The ‘break’ statement can be used in loop structure and switch statement. Each ‘try’ statement has only one corresponding ‘catch’ statement. The ‘continue’ statement represents that the program will continue execute next loop in loop structure. In Java, key word ‘new’ is used in creating new object of class, and ‘free’ is used in recycling useless object. If p is Parent object and c is child object, the statement p=c is right. When a method produce an exception at running time, this method will terminate, but the whole program may continue. 14. Abstract method should be in abstract class, so the methods in abstract class must be abstract ones. 15. The unit of screen coordinate(屏幕坐标) in Java is pixel, the lower left quarter(左下角) is defined as start-point of coordinate.
系(院) 计算机与通信学院
课程名称
Java 程序设计
密封线
第1页
共3页
《 Java程序设计》课程试题参考答案及答案
三. Fill in the blanks with proper Java statements(16 Points, 2 Points each blank)1. Please finish the following class and sub class. (1) Figure { // 定义抽象类 Figure double x,y; void set_size(double size1,size2) { x=size1; y=size2; } abstract double get_area(); // 定义抽象方法 get_area,它没有方法体 } class Triangle extends Figure { double get_area() { // 重写其父类的抽象方法 get_area() (2) ; } } { // Rectangle 继承抽象类 Figure class (3) double get_area() { return(x*y); } } 2. Please finish the following WindowListener class. private class MyWindowListener (4) { public void windowClosing(WindowEvent e) { int result = JOptionPane.showConfirmDialog(……); if(result == JOptionPane.OK_OPTION) (5) ; //退出系统 } } 3. Please finish the following client program of C/S communication. import java.io.*; import http://www.77cn.com.cn.*; public class TalkClient { public static void main(String args[]) { try{ Socket socket= (6) ; //向本机的 4700 端口发出客户请求 BufferedReader sin=new BufferedReader(new InputStreamReader(System.in)); PrintWriter os=new PrintWriter(socket.getOutputStream()); BufferedReader is=new BufferedReader(new InputStreamReader(socket.getInputStream())); String readline; readline=sin.readLine(); //从系统标准输
while(
学号
(7) ){ //若从标准输入读入的字符串为"bye"则停止循环 os.println(readline); os.flush(); System.out.println("Client:&q …… 此处隐藏:6374字,全部文档内容请下载后查看。喜欢就下载吧 ……
上一篇:养老护理员-第三章-饮食照料
下一篇:中国当代文学名词解释集锦