=========================preview======================
(COMP201)Sp04_201_final_sol.pdf
Back to COMP201 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY
COMP 201: Java Programming
Spring 2004
Final Examination
20, May 2004 4:30-7:30(pm) LG1
Solution
Student Name: Email Address:
Student Number: Lab Section/TA Name:
Instructions:
1. This is a closed-book, closed-notes examination.
2. Check that you have all
18 17 pages (including this cover page).
3. Write legibly. We cannot give grades to what we cannot understand. Dont use pencils.
4. The last Page lists some classes and methods that you might want to use when answering the programming questions.
5. Answer all questions in the space provided. Rough work should be done on the back pages.
Question Score / full score
1 /5
2 /30
3 /20
4 /1510
5 /15
6 /1520
Total /100
Question 1(5 marks, one mark for each correct answer) : Is each of the following statements true or false?
1.
The one-thread rule for Swing programming means that there can only be one thread in a Swing program.
Answer: ______________False________________________________________
2.
Both yieldand wait are called on Thread objects, i.e.
someThread.yield() and someThread.wait().
Answer: _______________ False _______________________________________
3.
It is possible to tell whether a thread is dead. Answer: ______________ False ________________________________________
4.
A callto yieldblocks a thread Answer: ____________ False __________________________________________
5.
The java.sql.Connection interface enables Java programs to communicate with DBMS using streams.
Answer: ____________ False __________________________________________
Question 2 (30 marks,) 3 marks for each correct answer):
1. Which of the following statements are correct regarding components and Events? Select all the the valid answers.
A. A menu can generate ActionEvent.
B. You can add an ActionListener to a TextArea
C. A ComponentListener can be added to a button.
D. A list can generate MouseEvent
E. A Panel can generate FocusEvent.
Answer: __________________________________________________________A C D E_____________________________________
2. Which of the following statements are not NOT true? Select all the valid answers.
A. An object hashas as many locks as the number of Synchronized instance methods.
B. A class has as many locks as the number of synchronized static methods.
C. An object can haves exactly one lock.
D. The lock of a class is independent of the lock its instance has.
E. The lock of an object is independent of lock of its class.
Answer: __________________________________________________________A B______________________________________________
3. Suppose that you using Borderlayout BorderLayout and add five components in all the five regions of this Layout. Which of the following statements are valid?
A. A Bottom right corner will be occupied by the component in East.
B. Top left c