Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Essentials of the Java Programming Language (Part II)

 

Quizzes Index

Programming Language
(Part II)


August 2000

Duke The Essentials of the Java Programming Language is a great resource to explore the Java platform. Take this short quiz to test your knowledge of exceptions, applet and database permissions, and RMI from Part I, and keywords, graphic user interfaces, and collection interfaces from Part II.

1. Select the answer that best describes the purpose of the following catch block:

try {
   // Write to file
   // Read from file
} catch (java.lang.IOException e) {
  // Do something if . . .
}


 A. Closes the file that has been written to and read.
 B. Catches an exception if the file is not available for reading or writing.
 C. Catches an exception if the System.getProperty call fails.


2. Two methods from the exception and error classes are useful for debugging an application during development. One of the methods is called a printStackTrace(). Another useful method for understanding errors is toString. Select the best description for the following block of code.

} catch(java.io.IOException e) {
  System.out.println(e.toString());
}
  
 A. This catch block is best for development to alert the programmer to errors or abnormal conditions.
 B. This catch block is best for deployment because it alerts the user to a problem and prints a meaningful message to the screen.
 C. This catch block does not serve any useful purpose.


3. The Java 2 platform security imposes restrictions on applets without explicit permissions to do the following:

 A. Display images
 B. Accept user input
 C. Write to system files
 D. Initialize data in the browser


4. In order to determine what permissions an applet's policy file needs to access a database, read the error messages from the:

 A. IOException method
 B. stack trace
 C. IllegalActionException Statement
 D. Datagram Packet


5. In Lesson 7, the database application prevents outside classes from accessing the database driver, the user name, and the password by declaring these variables as:

 A. public final
 B. protected final
 C. private final
 D. primitive data types


6. To run the RMI application in Lesson 8, you must first start:

 A. RMI Client 1
 B. RMI Registry
 C. Remote Server
 D. Send.java


7. What does a multithreaded server do?

 A. Handles threads for each communication it accepts from a client
 B. Uses and throws built-in IOExceptions
 C. Listens and handles events through the ActionListner interface
 D. Restricts threads with accessEventQueue


8. The synchronized keyword is used to:

 A. Run threads simultaneously
 B. Obtain a lock on an object
 C. Instantiate multiple objects
 D. Instantiate methods concurrently


9. The actionPerformed method in a user interface handles action events such as:

 A. Button-clicks and text field returns
 B. Data passing from GUI to server
 C. Multithread handling
 D. Database entries


10. The List interface implementation permits duplicate elements in a collection object.

 A. True
 B. False