Tutorial 3 PDF Java Event Handling

Summary

This document is a tutorial on Java event handling, covering various aspects of creating and responding to events in Java programs. It includes explanations of different event types and listener interfaces, along with code examples.

Full Transcript

**Tutorial 3** 1\. How to remove the event listener? a\) Using removeListener( ) method. **b) Using remove*Type*Listener( ) method.** c\) Using removeEvent( ) method. d\) It is not possible to remove the event listener 2\. At the root of Java event hierarchy, which class is located? a\) AWTEv...

**Tutorial 3** 1\. How to remove the event listener? a\) Using removeListener( ) method. **b) Using remove*Type*Listener( ) method.** c\) Using removeEvent( ) method. d\) It is not possible to remove the event listener 2\. At the root of Java event hierarchy, which class is located? a\) AWTEvent b\) Event **c) EventObject** d\) Events 3\. Action event is generated when... a\) Label is dragged **b) Button is pressed** c\) Mouse is dragged d\) Window is opened 4\. How to obtain the command name for invoking ActionEvent? **a) Using getActionCommand( ) method.** b\) Using getCommand( ) method. c\) Using getAction( ) method. d\) Using obtainAction( ) method. 5\. TextEvent defines the integer constant... a\) TEXT\_CHANGED **b) TEXT\_VALUE\_CHANGED** c\) TEXT\_ADDED d\) TEXT\_VALUE\_ADDED 6\. An event is generated whe the internal state of the event source is\_\_\_\_\_\_\_\_ 0 a\. Not changed b\. **Changed** c\. Either changed or not d\. None of these 7\. EventObject class belongs to: a\. **java.util** b\. java.awt c\. java.lang d\. java.sql 8\. The \_\_\_\_\_\_\_\_\_\_\_ interface handles choice events: a\. ContainerListener b\. **ItemListener** c\. ActionListener d\. WindowListener 9\. The \_\_\_\_\_\_\_\_\_\_\_ interface is used to handle checkbox events: a\. ContainerListener b\. **ItemListener** c\. ActionListener d\. WindowListener 10\. The \_\_\_\_\_\_\_\_\_\_\_ interface is used to handle button events: a\. ContainerListener b\. ItemListener c\. **ActionListener** d\. WindowListener 11\. ItemListener is defined by the \_\_\_\_\_\_\_\_\_\_\_\_\_ method: a\. itemChangedState() b\. **itemStateChanged()** c\. itemChanged() d\. itemState() 12\. \_\_\_\_\_\_\_\_\_\_\_\_\_ is a superclass of TextField and TextArea classes that is used to create single-line or multiline textfields respectively: a\. TextBox b\. CheckBox c\. **TextComponent** d\. Choice 13\. A label is a simple control which is used to display\_\_\_\_\_\_\_\_\_\_\_\_\_ on the window: a\. **Text(non-editable)** b\. Text(editable) c\. Both a & b d\. None of these 14\. The Delegation Event Model is based on the concept of \_\_\_\_\_\_\_\_\_\_\_\_\_ a\. Source b\. Listener c\. **Both a & b** d\. None of these 15\. A source generates an event and sends it to \_\_\_\_\_\_\_\_\_\_\_ listeners that can handle the event: a. One b\. Two c\. **One or more** d\. None of these 16\. \_\_\_\_\_\_\_ generates action events when an item is double-clicked, generate action events when an item is selected or deselected. a\. **List** b\. Check box c\. Menu item d\. Text box Label 17\. KeyEvent is generated in following sequence... a\) Key typed, pressed, released b\) Key released, typed, pressed c\) Key pressed, typed, released d\) **pressed, Key released, typed** 18\. Which method is not defined by MouseListener interface? a\) **mouseDragged( )** b\) mouseMoved( ) c\) mouseEntered( ) d\) mouseReleased( ) 19\...........package contains all the classes and methods required for Event handling in java. \(a) java.applet \(b) java.awt (c)java.event (d**)java.awt.event** 20\. method are used to register a keyboard event listener. \(a) KeyListener( ) \(b) addKistener() \(c) **addKeyListener()** \(d) eventKeyboardListener() 21\. \_\_\_\_\_ method are used to register a mouse motion listener. \(a) addMouseO \(b) addMouseListenerO \(c) **addMouseMotionListnerO** \(d) eventMouseMotionListenerO 22\. if we close an applet\'s window generated. event will be \(a) ActionEvent \(b) ComponentEvent \(c) AdjustmentEvent (d)**WindowEvent** 23\. Which of these are integer constants defined in ActionEvent class? \(a) ALT\_MASK \(b) CTRL\_MASK \(c) SHIFT\_MASK (d) **All of the mentioned** 24\. What are the KeyListener Interface? \(a) keyPressed \(b) keyReleased \(c) keyTyped **(d) All three** 25\. Which of these are constants defined in WindowEvent class? a\. WINDOW\_ACTIVATED b\. WINDOW\_CLOSED c\. WINDOW \_DEICONIFIED **d. All of the mentioned** 26\. interface define a method actionPerformed(). \(a) ComponentListener \(b) ContainerListener \(c) **ActionListener** \(d) InputListener 27\. Which method from the following methods will respond when you click any button by mouse? \(a) **mouseClicked**() \(b) mouseEntered() \(c) mousePressed() \(d) All of the mentioned 28\. methods will be invoked if a charaeter is entered. \(a) keyPressed() \(b) keyReleased() \(c) **keyTyped**() \(d) keyEntered() 29.The constructor that is defined by the Text Event class is: **a. TextEvenet(Object source, int event\_type )** b\. textevent (Object source, int event\_type ) c\. textevent (object Source, float event\_type) d\. textevent (Object source, string event\_type)

Use Quizgecko on...
Browser
Browser