Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Advanced Programming for the Java 2 Platform Quiz

 

Quizzes Index

2 Platform
Quiz



Duke

Find out how much you know about debugging and performance tuning on the Java 2 platform.

 

1. If classes, libraries, or Windows registry entries from previous installations remain on your system after an upgrade, there is a chance the new software mix might cause program problems.

 A. True
 B. False


2. What does the verbose option to the java interpreter command do?

 A. Lets you supply the class path you want to use.
 B. Turns on debug mode for the Java virtual machine1.
 C. Causes the Java virtual machine to dump a stack trace.
 D. Shows which zip or JAR file a class comes from when it is loaded.


3. The -Ddebug option to the java interpreter command lets you turn debug mode on from the command line. What are the advantages of doing this?

 A. You can rule out sequence problems caused by race conditions coming from System.out.println debug messages because you are not using System.out.println debug messages.
 B. You do not need to recompile code if problems appear at the testing stage or on a customer site.
 C. You do not have to remember to remove System.out.println debug messages when you deploy the application to production.
 D. All of the above.


4. Compiling with the debug flag adds debug information to the class. How can you reduce the size of these classes?

 A. Compile with the javac -g:none option.
 B. Compile with the javac -g option.
 C. Compile with the javac -Ddebug=false option.
 D. Compile with the javac -Ddebug=true option.


5. Is it possible to debug an applet running in applet viewer?

 A. Yes
 B. No


6. What is an agent password and when is it used?

 A. An encryption key to prevent intruders from illicitly retrieving your debug information.
 B. The password for reading the jdb session log.
 C. An identifier that lets jdb locate the application to debug for a remote debugging session.
 D. The password for turning debug information on at run time.


7. Servlets cannot be debugged with jdb.

 A. True
 B. False



8. You can use an AWTEventListener to monitor the AWT events in a system event queue. This listener takes an event mask built from an OR operation of the AWTEvents you want to monitor. How can you obtain a simple list of AWT events?

 A. Call javap -public java.awt.AWTEvent from the command line.
 B. Call javap -public events from the command line.
 C. Call javap -protected events from the command line.
 D. Call javap -protected java.awt.AWTEvent from the command line.


9. A stack trace is a snapshot of the threads and monitors in a Java virtual machine. When you see a stack trace, you will see different threads in many different states. What does the MW thread state mean?

 A. The thread is waiting on a condition variable.
 B. The thread is waiting on a monitor lock and could be in a deadlocked state.
 C. The thread is suspended waiting on a monitor lock.
 D. The thread is running.


10. What can network-based applications use to save on the time and overhead involved in opening and closing network connections?

 A. Thread pooling.
 B. A dynamic loading lock.
 C. JAR files.
 D. Connection pooling.


11. Cached database connections cannot be reused.

 A. True
 B. False


12. The Java 2 release of the Java virtual machine automatically inlines simple methods at run time. How does method inlining improve performance?

 A. Activates the Just-In-Time (JIT) compiler.
 B. Eliminates the need for garbage collection.
 C. Reduces the number of method calls your program makes.
 D. Ensures the integrity of the monitor cache.


13. Performance analysis is looking at program execution to pinpoint where bottlenecks or other performance problems such as memory leaks might occur. Which of the following tools let you analyze Java virtual machine heap profile reports?

 A. jdb
 B. Just-In-Time (JIT) compiler
 C. Heap Analysis Tool (HAT)
 D. kill -QUIT <process-ID>


14. What command lets you generate a text profile report?

 A. java -profilereport MyClass.
 B. java -profile MyClass.
 C. java -gen MyClass.
 D. java -Xrunhprof MyClass.


15. The Java virtual machine depends on many operating systems libraries for functionality, such as disk access or networking. However, what occurs in these libraries is of no consequence to performance.

 A. True
 B. False


16. Keeping objects in cached memory for rapid access is a common technique for improving performance. What is a simple algorithm to constrain cache size to limit the amount of memory dedicated to cached objects?

 A. Connection cache.
 B. Web proxy cache.
 C. Growing HashMap object.
 D. Most Recently Used (MRU) cache.


17. When do you need to install Java Plug-In?

 A. When you cannot use a JAR file.
 B. When you want to run an applet in a browser and the applet uses a later version of the Java APIs than is supported by the browser.
 C. When the applet needs to access local system resources.
 D. When your applet uses a lot of graphics.


18. A security policy file grants access permissions to an applet so the applet can access local system resources. There are three kinds of security policy files: system, user, and program. Where is the user policy file located?

 A. In the user's home directory.
 B. With the user's Java platform installation.
 C. Under the public_html directory on the user's machine.
 D. On the server where the applet resides.


19. By default the Java 2 platform software provides a security manager that disallows all access to local system resources.

 A. True
 B. False


20. The Java 2 platform security manager restricts all applets to a sandbox-like environment. How do you force an application to run under the Java 2 platform security manager and provide a security policy file with only limited permissions?

 A. java -Djava.security.manager
   -Djava.security.policy=policyfile MyProgram
 B. java -Djava.security.manager
 C. java -Djava.security.policy=policyfile MyProgram
 D. None of the above.