java进阶复习题(共34页).doc





《java进阶复习题(共34页).doc》由会员分享,可在线阅读,更多相关《java进阶复习题(共34页).doc(34页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上Name:_Covers Chs 29-31Sample ExamMultiple Choice Questions Only for This TestPart I: Questions: (1 pts each)1 You should always invoke the unlock method in the finally clause.A. true B. false 2 Given the following code, which set of code can be used to replace the comment so that the pr
2、ogram displays time to the console every second?import java.applet.*;import java.util.*;public class Test extends Applet implements Runnable public void init() Thread t = new Thread(this); t.start(); public void run() for(; ;) /display time every second System.out.println(new Date().toString(); A. t
3、ry Thread.sleep(1000); catch(InterruptedException e) B. try sleep(1000); catch(InterruptedException e) C. try Thread.sleep(1000); catch(RuntimeException e) D. try t.sleep(1000); catch(InterruptedException e) 3 Which of the following expressions must be true if you create a thread using Thread = new
4、Thread(object)?A. object instanceof Applet B. object instanceof Thread C. object instanceof Frame D. object instanceof Runnable 4 How do you create a condition on a lock?A. Condition condition = Lock.getCondition(); B. Condition condition = Lock.newCondition(); C. Condition condition = lock.getCondi
5、tion(); D. Condition condition = lock.newCondition(); 5 Which method on a condition should you invoke to causes the current thread to wait until the condition is signaled?A. condition.waited(); B. condition.await(); C. condition.waiting(); D. condition.wait(); 6 To run an object on a separate thread
6、, the object must be a subclass of Thread.A. true B. false 7 The Runnable interface is more general than the Thread class. You can convert any class that extends Thread to a class that implements Runnable.A. true B. false 8 An exception occurs if the resume() method is invoked by a finished thread o
7、bject.A. true B. false 9 You can set a priority for an object of ThreadGroup using the setPrority() method.A. false B. true 10 You must specify a name for the thread group that you will create.A. false B. true 11 You should not directly invoke the run() method of a thread object.A. true B. false 12
8、When creating a server on a port that is already in use, _.A. the server encounters a fatal error and must be terminated. B. the server is blocked until the port is available. C. the server is created with no problems. D. .BindException occurs. 13. To obtain an ObjectInputStream from a socket, use _
9、.a. socket.getInputStream()b. socket.getObjectStream()c. socket.getObjectInputStream()d. socket.objectInputStream()e. new ObjectInputStream(socket.getInputStream();Key:e14 You can invoke _ on a Socket object, say socket, to obtain an InetAddress object.A. socket.obtainInetAddress(); B. socket.InetAd
10、dress(); C. socket.retrieveInetAddress(); D. socket.getInetAddress(); 15 To connect to a server running on the same machine with the client, which of the following can be used for the hostname?A. InetAddress.getLocalHost(), B. 127.0.0.1 C. localhost D. All of the above. 16 The server listens for a c
11、onnection request from a client using the following statement:A. Socket s = serverSocket.accept() B. Socket s = new Socket(ServerName); C. Socket s = serverSocket.getSocket() D. Socket s = new Socket(ServerName, port); 17 The server can create a server socket regardless of whether the port is in use
12、 or not.A. true B. false 18 The client can connect to the server regardless of whether the port is in use or not.A. true B. false 19 You cannot get instances of InputStream or OutputStream because InputStream and OutputStream are abstract classes.A. true B. false 20 An applet cannot connect to a ser
13、ver program on a Web server where the applet was loaded.A. false B. true 21 You can transmit objects over the socket.A. false B. true 22 The URL constructor throws MalformedURLException if the URL is syntactically incorrect.A. true B. false 23 getInputStream() and getOutputStream() are used to produ
14、ce InputStream and OutputStream on the socket.A. false B. true 24 Which of the following statements are true?A. You can create an instance of NumberFormat using the static factory methods in NumberFormat. B. You can create an instance of DecimalFormat using new DecimalFormat(Local). C. DecimalFormat
15、 is a subclass of NumberFormat. D. An instance created using the static factory methods in NumberFormat is also an instance of DecimalFormat. E. You can create an instance of NumberFormat using new NumberFormat(Local). 25 Which of the following are in the java.text package?A. DateFormat B. SimpleDat
16、eFormat C. DateFormatSymbols D. Date E. Locale 26 Which of the following code is correct to obtain hour from a Calendar object cal? A. cal.getHour(); B. cal.get(Hour); C. cal.get(Calendar.HOUR); D. cal.hour(); 27 How do you create a locale for the United States? A. new Locale(en, US); B. new Locale(
17、US, en); C. Locale.getLocale(en, US) D. Locale.US; 28 A resource bundle is _A. a Java class file or a text file that provides locale-specific information. B. a Java source code the contains image, audio, and text files. C. an audio file. D. an image file. 29 To display number in desired format, you
18、have to use the NumberFormat class or its subclasses.A. true B. false 30 You can find all the available locales from a Swing object.A. true B. false 31 The locale property is in the Component class, thus, every Java Swing component has the locale property.A. true B. false 32 You can get year, month,
19、 day, hour, minute, and second from an instance of GregorianCalendar.A. true B. false 33 You can get hour, minute and second from the Date class.A. false B. true 34 The TimeZone class has a static method for obtaining all the available time zone IDs.A. false B. true 35 You can get all the available
20、locales from an instance of Calendar, Collator, DateFormat, or NumberFormat.A. false B. true Keys:1. A2. A3. D4. D5. B6. A7. A8. A9. A10. B11. A12. D13. D14. D15. D16. A17. B18. A19. B20. B21. B22. B23. B24. ACD25. ABC26. C27. AD28. A29. A30. B31. A32. A33. A34. B35. BName:_Covers Chs 32-35Sample Ex
21、amMultiple Choice Questions Only for This TestPart I: Questions: (1 pts each)1 An event adapter can be implemented using _.A. standard adapter B. inner class adapter C. anonymous inner class adapter 2 The signature for the accessor method of a Date property birthDate should be _.A. public java.util.
22、Date birthDate() B. public java.util.Date getBirthDate() C. private java.util.Date birthDate() D. private java.util.Date getBirthDate() E. public java.util.Date getbirthDate() 3 The signature for the mutator method of a Date property birthDate should be _.A. public void birthDate(java.util.Date date
23、) B. public void setBirthDate(java.util.Date date) C. public void setbirthDate() D. public void birthDate() 4 An event and its corresponding listener is referred to as _.A. an event set B. an event class C. an event pair D. an event object 5 Which of the following is true?A. A bean must implement th
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 进阶 复习题 34

限制150内