Quiz 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()

Correct Answer Is:


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.

Correct Answer Is:


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

a.    setSize()
b.    setDimensions()
c.    showSize()
d.    setRectangle()

Correct Answer Is:


4. What interface must a button listener implement?

a.    ActionListener
b.    ButtonListener
c.    ClickListener
d.    DeviceListener

Correct Answer Is:


5. What method must a button listener implement?

a.    buttonAction()
b.    eventAction()
c.    actionMethod()
d.    actionPerformed()

Correct Answer Is:


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

a.    setLayout()
b.    setLayoutManager()
c.    addLayout
d.    setManager()

Correct Answer Is:


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)

Correct Answer Is:


8. What class of events do button clicks create?

a.    ActionEvent
b.    ButtonEvent
c.    ClickEvent
d.    DemoEvent

Correct Answer Is:


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

a.    getCommand()
b.    getActionCommand()
c.    getCommandString()
d.    getButtonText()

Correct Answer Is:


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

a.    ==
b.    =
c.    equals()
d.    equalsIgnoreCase()

Correct Answer Is:


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

Click here (If you have just 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 on reload to clear the old answers.)