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.

Correct Answer Is:

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.

Correct Answer Is:

3. What is the class of Swing labels?

a.    JLabel
b.    Label
c.    SLable
d.    label

Correct Answer Is:

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.

Correct Answer Is:

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.

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 is used to read the text from a JTextField?

a.    readText()
b.    getText()
c.    getString()
d.    putText()

Correct Answer Is:

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

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

Correct Answer Is:

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.

Correct Answer Is:

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.

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