Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Advanced Programming for the Java 2 Platform Quiz - Part 2

 

Quizzes Index

2 Platform Quiz, Part Two

Advanced Programming Test your knowledge of Project Swing components from the book Advanced Programming for the Java 2 Platform.
1. Why is Project Swing more accurately described as a model-delegate architecture?
  A. Accessor methods in container classes let you manipulate the model (data).
  B. The controller part of a Project Swing interface, often the mouse and keyboard events the component responds to, is combined with the physical view in one user interface delegate object.
  C. The Project Swing data model is delegated to an underlying servlet.
  D. The user interface is completely separate from the controller.


2. Lightweight components depend on the local windowing toolkit.
 A. True
 B. False


3. JApplet, JDialog, JFrame, and JWindow are examples of heavyweight components.
 A. True
 B. False


4. What class controls the order in which components are drawn in their top-level container?
 A. JContainer
 B. JRootPane
 C. JLayeredPane
 D. JFrame


5. What does the following code do?
JButton enterButton = new JButton("Enter");
   layeredPane.add(enterButton, LayeredPane.Default_Layer, 0);
   

 A. Adds a JButton to the default layer and specifies that it appear behind the other components in that same layer.
 B. Adds a JButton to the default layer and specifies that it appear behind all heavyweight components in that same layer.
 C. Adds a JButton to the default layer and specifies that it appear on top of the drag-and-drop layer.
 D. Adds a JButton to the default layer and specifies that it appear in front of the other components in that same layer.


6. What do you normally need to implement a custom table model?
 A. Extend AbstractTableModel or DefaultTableModel
 B. Implement a method to return the number of rows and another one to return the number of columns.
 C. Implement a method to retrieve an element at a specific location.
 D. All of the above.


7. What is the key to adding a footer or header to pages printed from an application written in the Java programming language?
 A. Adding additional paint calls to print additional components.
 B. Using the PageFormat and Book classes.
 C. Using the translate and setClip methods in the Graphics2D class.
 D. Adding additional print calls to print additional components.


8. How do you print a large component that will only fit on multiple pages?
  A. Calculate the total number of pages needed to contain the component by subtracting the space taken by the component from the value returned by the getImageableHeight method and then call the print method for each page on a translated and clipped section of the component.
  B. Use the Book class to automatically calculate the page breaks.
  C. Call the paint method multiple times from your print method implementation.
  D. Call the print method multiple times from your paint method implementation.


9. Which methods in the SwingUtilities class give you some control over the event queue?
 A. isEventDispatchThread
 B. invokeLater and invokeAndWait
 C. getUIActionMap
 D. notifyAction


10. The JList class lets you display data in a selectable list, and uses uses a DefaultListSelectionModel to enable user selections. Which selection mode is not available to the DefaultListSelectionModel class?
 A. MULTIPLE_INTERVAL_SELECTION
 B. SINGLE_INTERVAL_SELECTION
 C. SINGLE_SELECTION
 D. MULTIPLE_SELECTION