Quiz on Buttons

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 three types of software are needed in a complete GUI program

a.    GUI Components, Event Listeners, Application Code
b.    Action Events, Window Objects, Containers
c.    Frames, Windows, Containers
d.    Libraries, Toolkits, Interfaces

Correct Answer Is:

2. How is a GUI component (such as a button) placed into a JFrame?

a.    insert( Component c )
b.    getContentPane().add( Component c )
c.    draw( Component c )
d.    getContentPane().put( Component c )

Correct Answer Is:

3. What is the Java software that determines how the components of a container are displayed?

a.    Display Manager
b.    Component Manager
c.    Stage Manager
d.    Layout Manager

Correct Answer Is:

4. Which manager displays components row-by-row, in the order in which they were added to the Frame?

a.    CardLayout
b.    FlowLayout
c.    GridLayout
d.    BorderLayout

Correct Answer Is:

5. What method of a Frame is used to choose the layout manager?

a.    setLayout()
b.    add()
c.    actionPerformed()
d.    setVisible()

Correct Answer Is:

6. What interface must a class implement in order to be a listener for button ActionEvents?

a.    TextListener
b.    Runnable
c.    ActionListener
d.    ImageConsumer

Correct Answer Is:

7. What method must be implemented in a listener for button events?

a.    paint()
b.    windowClosing()
c.    addActionListener()
d.    actionPerformed()

Correct Answer Is:

8. What method of a content pane changes its color?

a.    setBackground( Color c )
b.    setForeground( Color c )
c.    add()
d.    getBackground()

Correct Answer Is:

9. When should your program call repaint()?

a.    Never--that is the system's job.
b.    Only once when the frame is created.
c.    Whenever a change has been made that should result in a new picture.
d.    Always---whenever any method finishes.

Correct Answer Is:

10. What method will immediately stop a program?

a.    System.gc()
b.    System.exit( 0 )
c.    System.setErr()
d.    return()

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.)