Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Multiple Choice for Java Please answer the questions correctly. 1: JButtons gene

ID: 3565694 • Letter: M

Question

Multiple Choice for Java

Please answer the questions correctly.

1: JButtons generate what type of event?

2: A JFrame supports three operations when the user closes the window. Which of the choices below is not one of the three:

3: Which of the following is not one of the seven methods for handling window events?

4: Which of the following is false?

.5: What happens if setSize is not called on a JFrane (assume pack is not called)?

6: Which of the following does not generate GUI events?

a. Typing in a text field.

b. Selecting an item from a menu.

c. Displaying the text in a label.

d. Moving the mouse.

7: Which of the following most completely describes the steps for setting up event handling for a GUI component?

a. Create a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler.

b. Implement an appropriate event-listener interface and register the event handler.

c. Create a class that represents the event handler and implement an appropriate event-listener interface.

d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

8: When the user presses Enter in a JTextField, the GUI component generates an         , which is processed by an object that implements the interface         .

a. ActionEvent, ActionListener.

b. ActionEvent, ActionEventListener.

c. TextEvent, TextListener.

d. TextEvent, TextEventListener.

9: Forgetting to register an event-handler object for a particular GUI component

Explanation / Answer

1)
1.ActionEvents


2)
3. LOWER_ON_CLOSE


3)
3. windowOpening


4)
1. JFrame is a lightweight component


5)
1. The window is displayed at its preferred size


6)
c. Displaying the text in a label


7)
d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

8)
c. TextEvent, TextListener.


9)
a. events of that type to be ignored.

10)

c. getText


11)
c. one or more


12)
d. ButtonGroup


13)
b. causes all the JRadioButtons in the group to have their event handlers registered.


14)
c. They are declared with the anonymous keyword.


15)
a. JTextField

16)
c. mouseDragged

17)
d. MouseListener only


18)
c. When it is not desirable to declare every method in the event-listener interface.


19)
c. keyClicked