=========================preview======================
(COMP201)summer07_final_solution.pdf
Back to COMP201 Login to download
======================================================
THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
COMP 201: Java Programming
Summer 2007
Final Examination
10-12 August 8, LTB
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
2
3
4
5
6
7
8
9
10
If a JComponent is not displayed, its getGraphics method will return null.
Calling repaint in a program causes paintComponent to be invoked automatically.
The order of adding components does not matter for FlowLayout.
Every event object has a getActionCommand method.
An inner class can be declared static.
A JDialog object can be added as a component to a panel.
The yield method in the Thread class is deprecated.
The execution of a Java servlet in a servlet engine is multi-threaded.
A SQL PreparedStatement object can execute a query but not an update.
A JSP can directly use the out object without declaring it.
Circle your answers (one circle per question) in the following answer sheet:
1
2
3
4
5
6
7
8
9
T
T
F
F
T
F
F
T
F
10
T
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 is the default layout of the contentPane of a JApplet?
A) BorderLayout
B) FlowLayout
C) GridLayout
D) None of the above
2. Given a Graphics object g, which of the following draws a circle of radius 20 centered at (50, 50) ?
A) g.drawOval(20,20,30,30);
B) g.drawOval(30,30,20,20);
C) g.drawOval(30,30,40,40);
D) g.drawOval(50,50,40,40);
3. Which of the following classes is not a subclass of Component?
A) Button
B) Checkbox
C) Font
D) Label
4. Which of the following information is not provided by an HTTPServletRequest object?
A) Buffer size
B) Cookies
C) Query string
D) Session
5. In which of the following statements does a server listen for a clients connection request?
A) Socket socket = new Socket(serverName, portNumber);
B) Socket socket = serverSocket.accept();
C) Socket socket = serverSocket.getClientSocket();
D) Socket socket = serverSocket.listen();
6. Which of the following types of event is fired by a JScrollbar object?
A) ActionEvent
B) AdjustmentEvent
C) ItemEvent
D) WindowEven