revised: 10/05/03

Quiz on Component Layout

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. How may numbers be entered into a graphical interface?

A.    The user types text into a text box. The program must convert the text into a primitive numeric type.
B.    The user must push "num lock" on the keyboard so numbers, not text are entered.
C.    The user enters digits into a text box; the text box returns numeric data to the program.
D.    Unless the digits are surrounded with quote marks, they are automatically numeric data.

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

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

3. What is the class of Swing labels?

A.    JLabel
B.    Label
C.    SLable
D.    label

4. How does FlowLayout() put components into the content frame?

A.    By rows starting at the top, then left to right in each row.
B.    Starts at the bottom, then right to left in each row.
C.    Starts at the center, then spirals outward.
D.    Puts the first component in the center, then squeezes the rest in around it.

5. When does a text field generate an action event?

A.    When the field has focus and the enter key is hit.
B.    For every character that is typed into the field.
C.    Whenever the frame has focus and the enter key is hit.
D.    When the text field looses focus.

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

A.    TextListener
B.    Runnable
C.    ActionListener
D.    ImageConsumer

7. What method is used to read the text from a JTextField?

A.    readText()
B.    getText()
C.    getString()
D.    putText()

8. What type of event does a button click generate?

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

9. A certain graphical interface contains several components that generate action events. What should be done so that the different events can be recognized?

A.    Use setEditable( true ) with each component.
B.    Use setActionCommand() with each component.
C.    Make every component a different type.
D.    The listener looks at the values in the variables to deduce which component an event is from.

10. If the user changes the size of the frame, what happens to the graphical components?

A.    They stay where they are; the frame just gets bigger.
B.    The layout manager changes the layout and re-distributes the components.
C.    The user can not change the size of a frame if the program used setSize.
D.    repaint() calls the frame's constructor, which puts everything back they way it started.

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.