Professional Documents
Culture Documents
Chapter 18
Section 18.1
18.1 Q1: __________ sockets and the __________ protocol will be more desirable for the vast majority of Java
programmers.
a.Stream, UDP.
b.Stream, TCP.
c.Datagram, UDP.
d.Datagram, TCP.
ANS: b. Stream, TCP.
Section 18.2
18.2 Q1: Using a URL as an argument to the __________ method of interface AppletContext causes the
browser in which the applet is executing to display the URL.
a.showURL.
b.showFile.
c.showHTML.
d.showDocument.
ANS: d. showDocument.
18.2 Q2: A _________ is thrown when a String that is not in proper URL format is passed to a URL constructor.
a.URLError.
b.URLException.
c.IllFormedURLException.
d.MalformedURLException.
ANS: d. MalformedURLException.
Section 18.3
Section 18.4
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 2 of 4
18.4 Q2: Once the ServerSocket is established, the server can listen indefinitely (or block) for an attempt by a
client to connect. This is accomplished with a call to the ServerSocket __________ method.
a.connect.
b.block.
c.accept .
d.listen.
ANS: c. accept.
Section 18.5
18.5 Q1: If an ObjectStream is used to read information from the server, an __________ is generated when the
client attempts to read a value from a stream on which end-of-stream is detected.
a.EOF.
b.EOS.
c.EOFException.
d.EOSException.
ANS: c. EOFException.
18.5 Q2: A(n) __________ is thrown when a server address indicated by a client cannot be resolved.
a.ConnectException.
b.ServerException.
c.MalformedURLException.
d.UnknownHostException.
ANS: d. UnknownHostException.
Section 18.6
18.6 Q1: Output __________ is/are typically used to increase the efficiency of an application by sending larger
amounts of data fewer times.
a.Objects.
b.Broadcasters.
c.Bounding.
d.Buffers.
ANS: d. Buffers.
18.6 Q3: The port number at which the server waits for connections is often called the __________ point.
a.Handhold.
b.Handshake.
c.Handoff.
d.Handle.
ANS: b. Handshake.
Section 18.7
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 3 of 4
18.7 Q2: Specifying a port that is already in use or specifying an invalid port number when creating a
DatagramSocket results in a __________.
a.PortInUseException.
b.PortException.
c.ConnectException.
d.SocketException.
ANS: d. SocketException.
Section 18.8
18.8 Q1: In the Tic-Tac-Toe program in the text, in class TicTacToeClient we implemented interface
__________ so that a separate thread could be used to continually read messages sent from the server to the client.
a.Runnable.
b.ThreadRemote.
c.Multithread.
d.Threadlocal.
ANS: a. Runnable.
Section 18.9
Section 18.10
(none)
Section 18.10.1
18.10.1 Q2: To send a DatagramPacket to a multicast address so that clients may access it, use
a.DatagramPacket method send( InetAddress address ).
b.DatagramSocket method send( DatagramPacket packet ).
c.DatagramSocket method send( String address ).
d.None of the above.
ANS: b. DatagramSocket method send( DatagramPacket packet ).
Section 18.10.2
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 4 of 4
D.Creating a bank of methods for which the code is hidden so that the classes which implement the
interfaces don’t have to define them.
a.All of the above.
b.None of the above.
c.B, C and D.
d.A, B and C.
ANS: d. A, B and C.
Section 18.11
18.11 Q1: The new I/O APIs in J2SE 1.4 enable developers to ____________.
a.Build non-blocking I/O without multithreading.
b.Halt the program when an input or output operation was called.
c.Build interactive server and client.
d.Write to a file simultaneously.
ANS: a. Build non-blocking I/O without multithreading.
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.