You are on page 1of 4

Java How to Program, 5/e Test Item File 1 of 4

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.

18.1 Q2: Which statement is false?


a.With datagram sockets a process establishes a connection to another process.
b.The TCP protocol is used for transmission with stream sockets.
c.The UDP protocol is used for transmission with datagram sockets.
d.With the UDP protocol packets can be lost, duplicated, or even arrive out of sequence.
ANS: a. With datagram sockets a process establishes a connection to another process.

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

18.3 Q1: Which statement is false? Normally, an applet


a.Is allowed to read files only on the server from which the applet was downloaded.
b.Can read files on any server that can be reached over the network.
c.Cannot read files on the system on which it executes.
d.Has different file access rights than an application running on the same machine.
ANS: b. Can read files on any server that can be reached over the network.

18.3 Q2: A JEditorPane generates HyperlinkEvents only if it is __________.


a.invisible.
b.visible.
c.uneditable.
d.editable.
ANS: c. uneditable.

Section 18.4

18.4 Q1: Which statement is false?


a.With sockets, network I/O appears to Java programs to be identical to sequential file I/O.
b.Network programming with sockets is complex.
c.Java multithreading makes it easy to create multithreaded servers.
d.UNIX, Windows NT and OS/2 all enable the creation and use of multithreaded servers.

© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 2 of 4

ANS: b. Network programming with sockets is complex.

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 Q2: The Internet address 127.0.0.1 is also known as __________.


a.Remotehost.
b.Localserver.
c.Remoteserver.
d.Localhost.
ANS: d. Localhost.

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

18.7 Q1: Which statement is false?


a.Streams-based transmission is connection-oriented.
b.Connection-oriented transmission is like the telephone system.
c.Datagram-based transmission is connection oriented.
d.Connectionless transmission is like the way the mail is carried by the postal service.
ANS: c. Datagram-based transmission is connection oriented.

© 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

18.9 Q1: Which statement is false?


a.Our efforts at writing powerful network-based applications are often crimped because of limitations imposed
on Java because of security concerns.
b.By default, applets can perform file processing only on the machines on which they run.
c.Web browsers often restrict an applet so that it can only communicates with the machine from which it was
originally downloaded.
d.Signed applets enable browsers to determine if an applet is downloaded from a trusted source.
ANS: b. By default, applets can perform file processing only on the machines on which they run.

Section 18.10

(none)

Section 18.10.1

18.10.1 Q1: Which statement is false?


a.Interfaces can be used to store constant values so that objects can access them easily.
b.Constants should be written in capital letters with underscores separating words.
c.Constants should be declared with the keywords public constant followed by the class name, variable
name, and value.
d.Constants should be declared with the keywords public static final followed by the class name,
variable name, and value.
ANS: c. Constants should be declared with the keywords public constant followed by the class name,
variable name, and value.

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

18.10.2 Q1: Advantages of using interfaces include which of the following:


A.Flexibility in implementation and in accommodating later functionality.
B.Providing standard values for many different classes to use.
C.Increasing opportunities to use polymorphism.

© 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.

You might also like