Questions for Java How Program, Third Edition

estrapadesherbetSoftware and s/w Development

Nov 18, 2013 (3 years and 10 months ago)

112 views

CPSC426 Java


EH52

1





Exercise/Homework EH52


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:


Q2: Which statement is false?

a.
With datagram soc
kets 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 arri
ve out of sequence.


ANS
:



Q3
: 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:



Q4
: A
(n)

_________ i
s 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:



Q5
: Which statement is false? Normally, an applet

a.
Is allowed to read files only on the se
rver 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:



Q6
: A
JEditorPane

generates
HyperlinkEvents

only if it is __________.

a.
invisible.

b.
visible.

c.
uneditable.

d.
editable.


ANS:




CPSC426 Java


EH52

2




Q7
: Which statement is false?

a.
With sockets, network I/O appears to Java programs to be identical to sequential file I/O.

b.
Network prog
ramming 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.


ANS:



Q8
: Once the
ServerSocket

is established, the server can liste
n 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:




Q9
: 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:



Q10
: A(n) __________ is thrown when a server address indicated by a client cannot be resolved.

a.
Conn
ectException
.

b.
ServerException
.

c.
MalformedURLException
.

d.
UnknownHostException
.


ANS:


Q11: Use a socket connection to allow a client to specify a file name and have server send the contents of the file or
indicate that the file does not exist.



ANS: