revised: 10/05/03


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. From what immediate base class is JTextField derived?

A.    JText
B.    JField
C.    JTextComponent
D.    JComponent

2. What goes in the blanks so that a text field of 20 characters is put into the frame?

  public TextExample()
  {  
    text = new JTextField( ____ ) ;
    getContentPane()._________( new FlowLayout() );
    getContentPane().add( ____ )
  }

A.    text, setLayout, 20
B.    20, setLayout, text
C.    20, put, frame
D.    20, set, text

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.    Starts 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. When the user is typing into a text field may corrections be made?

A.    No, each character is sent to the application program as soon as it is typed.
B.    No, hitting backspace or delete terminates input.
C.    Yes, up until the enter key is hit.
D.    Yes, but only by deleting the entire line and starting over.

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

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

8. Can the program put text into a JTextField?

A.    No, only the user can enter text.
B.    Yes, by using a JLabel
C.    Yes, by using setEditable()
D.    Yes, by using a putText()

9. How can the user be prevented from entering text into a text field?

A.    By using setEditable( true )
B.    By using setEditable( false )
C.    By using setNotEditable()
D.    By using setVisible( false )

10. What method changes the color of a content pane?

A.    setColor()
B.    setBackgroundColor()
C.    setBackground()
D.    setForegroundColor()

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.