Quizzes Index
2 Platform Quiz
By Monica Pawlan and Calvin Austin
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.
2. What does the verbose option to the java interpreter command do?
verbose
java
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?
-Ddebug
System.out.println
4. Compiling with the debug flag adds debug information to the class. How can you reduce the size of these classes?
debug
javac -g:none
javac -g
javac -Ddebug=false
javac -Ddebug=true
5. Is it possible to debug an applet running in applet viewer?
6. What is an agent password and when is it used?
jdb
7. Servlets cannot be debugged with jdb.
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?
AWTEventListener
OR
AWTEvents
javap -public java.awt.AWTEvent
javap -public events
javap -protected events
javap -protected java.awt.AWTEvent
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?
MW
10. What can network-based applications use to save on the time and overhead involved in opening and closing network connections?
11. Cached database connections cannot be reused.
12. The Java 2 release of the Java virtual machine automatically inlines simple methods at run time. How does method inlining improve performance?
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?
kill -QUIT <process-ID>
14. What command lets you generate a text profile report?
java -profilereport MyClass
java -profile MyClass
java -gen MyClass
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.
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?
HashMap
17. When do you need to install Java Plug-In?
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?
public_html
19. By default the Java 2 platform software provides a security manager that disallows all access to local system resources.
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?
java -Djava.security.manager -Djava.security.policy=policyfile MyProgram
java -Djava.security.manager
java -Djava.security.policy=policyfile MyProgram