revised: 10/05/03


on Buttons and Action Events

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.



1. What method (of a frame) returns a reference to its content pane?

A.    getContentPane()
B.    contentPane()
C.    framePane()
D.    getPane()

2. What type of object determines where GUI components go in the content pane?

A.    The layer organizer.
B.    The layabout programmer.
C.    The layout manager.
D.    The frame hanger.

3. What method determines the size of the frame on the screen?

A.    setSize()
B.    setDimensions()
C.    showSize()
D.    setRectangle()

4. What interface must a button listener implement?

A.    ActionListener
B.    ButtonListener
C.    ClickListener
D.    DeviceListener

5. What method must a button listener implement?

A.    buttonAction()
B.    eventAction()
C.    actionMethod()
D.    actionPerformed()

6. What method of a frame's content pane is used to set the layout manager?

A.    setLayout()
B.    setLayoutManager()
C.    addLayout
D.    setManager()

7. What method of class JButton sets the command string for a button?

A.    setActionCommand(String command)
B.    setCommand(String command)
C.    setCommandString(String command)
D.    setButtonCommand(String command)

8. What class of events do button clicks create?

A.    ActionEvent
B.    ButtonEvent
C.    ClickEvent
D.    DemoEvent

9. What method extracts the command string from an event object?

A.    getCommand()
B.    getActionCommand()
C.    getCommandString()
D.    getButtonText()

10. How should a command string be compared with a literal string?

A.    ==
B.    =
C.    equals()
D.    equalsIgnoreCase()

The number you got right:       Percent Correct:       Letter Grade:   


Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.