QUIZ

CHAPTER 14

Your Name:


14.1 If elephant.jpg is an image file in the same directory as an applet which is currently running, a Java statement to access it would be:

(a) Image e = elephant.getImage();
(b) Image e = getImage(this, elephant);
(c) Image e = getImage(getCodeBase(), "elephant.jpg");
(d) Image e = (MediaTracker) getImage("elephant.jpg");

14.2 In the statement

a.b = a.createImage((ImageProducer)imagename.getContent());

what is the class of imagename?

(a) URL
(b) ImageProducer
(c) Image
(d) Object

14.3 In Example 14.4 (ATM server), a handler thread can call server.closeDown() if a special message is received. When will the server react to the message?

(a) immediately
(b) when it comes round its while-loop again
(c) after the next client has joined
(d) b and c

14.4 What is the difference between a socket and a server socket in Java's APIs?

(a) a socket resides on the client and a server socket on the server
(b) both reside on the server, but the server socket can listen for new clients
(c) ServerSocket is a class and socket is an object
(d) server sockets listen for new clients and sockets reside on both sides to make the connection

14.5 What is the URL tag for displaying an image?

(a) <IMAGE = ...>
(b) <IMG SRC = ...>
(c) <IMG = ...>
(d) <DISPLAY .= ...>

14.6 Suppose we have another class in Example 14.6 called Secret, which also implements the Transferable interface. Leaving out exception handling, a statement to bind s, an object of class Secret, in the RMI registry would be:

(a) Naming.rebind (Secret, s);
(b) Naming.rebind ("Secret Service", s);
(c) s.rebind ("Secret Service");
(d) Naming.rebind (s);

14.7 The Socket class is declared in the java package called

(a) java.lang
(b) java.net
(c) java.util
(d) java.rmi

14.8 If con is a database connection, then a Java statement to create an object to hold an SQL query would be:

(a) String s = con.readln();
(b) Statement s = con.createStatement();
(c) Statement s = con ("SELECT");
(d) String s = con.create("SELECT");

14.9 Before we can write database programs in Java, we need to

(a) set up a suitable JDBC driver
(b) set up a suitable JDBC or OBDC driver
(c) set up a suitable JDBC driver or JDBC:OBDC bridge
(d) call Class.forName()

14.10 The RMI compiler (rmic) must be run on

(a) all classes that are part of an RMI system
(b) only the client classes
(c) only the server classes
(d) only the remote object classes