=========================preview======================
(COMP201)summer06_final_solution.pdf
Back to COMP201 Login to download
======================================================
THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
COMP 201: Java Programming
Summer 2006
Final Examination
3-5pm August 6, LTA
Student Name: SOLUTION ITSC Account: ____________________
Student ID: Lab Section:
Instructions:
1.
This is a closed-book, closed-notes examination.
2.
Check that you have all of the 11 pages (including this cover page).
3.
Text in Courier is Java source code.
4.
Answer questions in the designated space.
5.
Make sure your final answers are clearly recognizable.
Section Score / Full Score
I /20
II /30
III /30
IV /20
Total /100
Section I. True/False Questions (10 questions, 2 points per question)
1 All subclasses of IOException are checked exceptions.
2 The default layout of JPanelis BorderLayout.
3 A subclass has no access to a private field of its superclass.
4 When an event occurs, the event source object will notify all event listeners added to the object.
5 The data type byte in Java has a value range of [0, 255].
6 In Java 5.0, the stop method of Thread has deprecated.
7 To extend HttpServlet to implement a Java Servlet, we must override the doGet method.
8 We can use a DriverManager to obtain a JDBC connection with a database server.
9 We can use an XPath object to query the content of an XML document.
10 Any Java objects can be saved into a file using ObjectOutputStream.
Circle your answers (one circle per question) in the following answer sheet:
1 2 3 4 5 6 7 8 9 10
T F T T F T F T T F
Section II. Multiple-Choice Questions (10 questions, 3 points per question) Note: Select only one choice as your answer for each question
1.
Which of the following adds an etched border to a panel?
A) panel.addEtchedBorder();
B) panel.add(new EtchedBorder());
C) panel.addBorder(new EtchedBorder());
D) panel.setBorder(new EtchedBorder());
2.
Which of the following cannot connect to a web site to get a web page?
A) Connection
B) URLConnection
C) HttpURLConnection
D) Socket
3.
Which of the following exceptions is checked by the Java compiler?
A) ClassCastException
B) CloneNotSupportedException
C) IllegalArgumentException
D) NumberformatException
4.
Which of the following is true about inheritance and interfaces?
A) A class that implements an interface must have a default constructor.
B) A class that extends a superclass must have a default constructor.
C) If a class implements an interface, it must implement all methods of the interface.
D) If a class extends a superclass, it must implement all methods of the superclass.
5.
A Reader object reads a sequence of
A) bytes
B) characters
C) files
D) streams
6.
Which of the following types of event handlers can be added to a JSlider object?
A) ActionListener
B) ChangeListener
C) MouseListener
D) ScrollListener
7.
Which of the following classes has the method getColumnCount() method to return the number of