CPSC150 EH29 3

CPSC150 EH29

Q1: In a dedicated drawing area:

a. the user can draw by dragging the mouse.

b. the drawing is saved to a file.

c. the user can draw, but the drawing won’t appear until the user hits the F1 key.

d. the drawing must be saved as an object of class DedicatedDrawing.

Q2: Method paintComponent is called when:

a. a lightweight Swing component is created.

b. a lightweight Swing component is displayed.

c. a lightweight Swing component is clicked.

d. an application exits.

Q3: When a component is , paintComponent clears the component’s background before the component is displayed.

a. transparent.

b. opaque.

c. oblique.

d. concave.

Q4: Class Point represents:

a. a filled oval.

b. an x-y coordinate.

c. an object used to draw.

d. a period in a sentence.

Q5: Method indicates that a Component should be refreshed on screen as soon as possible with a call to that control’s paintComponent method.

a. refresh.

b. repaint.

c. repaintComponent.

d. redraw.

Q6: Which of the following is not a KeyListener method?

a. keyPressed.

b. keyReleased.

c. keyClicked.

d. keyTyped.

Q7: The Shift key is a(n) key.

a. modifier.

b. action.

c. output.

d. None of the above.

Q8: Using layout managers:

a. provides the greatest level of control over a GUI’s appearance.

b. can be faster than creating a GUI with absolute positioning.

c. allows the programmer to specify the exact location of each GUI component with respect to the upper-left corner of the Container.

d. allows the programmer to specify the exact location of each GUI component with respect to the lower-left corner of the Container.

Q9: All layout managers implement the interface:

a. LayoutInterface.

b. InterfaceLayoutManager.

c. LayoutManagerInterface.

d. LayoutManager.

Q10: Each container can have:

a. only one layout manager.

b. one or more layout managers.

c. zero or more layout managers.

d. only one or two layout managers.

Q11: BorderLayout implements interface:

a. ActionListener.

b. FlowLayout.

c. Layout.

d. LayoutManager2.

Q12: The class GridLayout constructs to hold components.

a. a horizontal grid with one row.

b. a vertical grid with one column.

c. a grid with multiple rows and columns.

d. a square grid with the same number of rows as columns.

Q13: Which of the following statements about JPanels is not true?

a. A JPanel is a JComponent.

b. A JPanel is a Container.

c. A JPanel does not have a content pane.

d. A JPanel has a fixed size.

Q14: A JTextArea:

a. provides a bounding box used for the layout of JTextFields.

b. wraps lines by default.

c. provides an area for manipulating multiple lines of text.

d. provides scrollbars for JTextFields.

Q15: By default JScrollPane:

a. always displays scrollbars.

b. never displays scrollbars.

c. only displays scrollbars if they are needed.

d. None of the above.

Q16:

It is often useful to display the events that occur during the execution of an application. This can help you understand when the events occur and how they are generated. Write an application that enables the user to generate and process every event discussed in this chapter. The applicationshould provide methods from the ActionListener, ItemListener, ListSelectionListener, MouseListener, MouseMotionListener, and KeyListener interfaces to display messages when theevents occur. Use method toString to convert the event objects received in each event handler into a String that can be displayed. Method toString creates a String containing all the information in the event object.