Event Handling Assignment No 3.pdf

Full Transcript

Assignment No 3 Event Handling Q. 1 The ActionListener interface is used for handling action events, For example, it's used by a (a) JButton (b) JCheckbox (c) All of these (d) JMenuItem Q. 2 Which class is used for this Processing Method processAct...

Assignment No 3 Event Handling Q. 1 The ActionListener interface is used for handling action events, For example, it's used by a (a) JButton (b) JCheckbox (c) All of these (d) JMenuItem Q. 2 Which class is used for this Processing Method processActionEvent( )? (a) Button,List,MenuItem (b) Button,Checkbox,Choice (c) Scrollbar,Component,Button (d) None of the above Q. 3 In Graphics class Which method is used to set the graphics current color to the specified color? (a) public abstract void setFont(Font font) (b) public abstract void setColor(Color c) (c) public abstract void drawString(String str, int x, int y) (d) None of the above Q. 4 Which of the following method is used to determine the type of adjustment event? (a) getType( ) (b) getEventType( ) (c) getAdjustmentType( ) (d) getEventObjectType( ) Q. 5 TextField generates event. (a) ActionEvent,ItemEvent (b) ActionEvent, TextEvent (c) ScrollEvent,TextEvent (d) ActionEvent, ScrollEvent Q.6 void keyTyped(KeyEvent ke) called when a key on the keyboard is. (a) pressed and then released. (b) pressed (c) released (d) none of the above Q. 7 Which event is generated when the position of scrollbar is changed? (a) KeyEvent (b) MouseEvent (c) ItemEvent (d) AdjustmentEvent Q. 8 The signature for the registration method for a ActionEvent should be. (a) public void addActionListener(ActionEvent L) (b) public void setAction(ActionListener L) (c) public void setActionListener(ActionListener L) (d) public void addActionListener(ActionListener L) Q. 9 Which of the following component generates ActionEvent? (a) Window (b) RadioButton (c) ScrollBar (d) None Q. 10 method is used to register a keyboard event listener. (a) KeyListener( ) (b) addKeyListener( ) (c) addKeyListenerEvent( ) (d) eventKeyboardListener( ) Q. 11 Name the method defined in EventObject class that returns the object generated from the event. (a) getEvent( ) (b) getObject( ) (c) getId( ) (d) getSource( ) Q. 12 The MouseListener interface is used to make mouse handling. (a) True (b) False Q. 13 ActionEvent is applied on (a) Frame (b) Checkbox, Choice, List (c) Scrollbar (d) Button, TextField, List, Menu Q. 14 ComponentEvent is the super class of. (a) FocusEvent (b) MouseEvent (c) WindowEvent (d) All of the above Q. 15 If we close an applet window events will be generated. (a) ActionEvent (b) ComponentEvent (c) AdjustmentEvent (d) WindowEvent Q. 16 Which of the following component generate ActionEvent? (a) ScrollBar (b) Window (c) RadioButton (d) None of these Q. 17 Which Listener handles all List related Events? (a) ItemListener (b) InputEvent (c) SelectEvent (d) ListEvent Q. 18 How to obtain the command name for invoking ActionEvent? (a) getCommandName( ) (b) getActionEventCommand( ) (c) getActionCmd( ) (d) getActionCommand( ) Q. 19 ComponentEvent is the superclass of (a) ActionEvent (b) ItemEvent (c) TextEvent (d) All of above Q. 20 When we need to use Checkbox or Item from the list or use a checkable Menu an is generated. (a) ActionEvent (b) ItemEvent (c) MenuEvent (d) ClickEvent Q. 21 Which of the following constant is not defined in WindowEvent class? (a) WINDOW_ACTIVATED (b) WINDOW_CLOSED (c) WINDOW_DEICONIFIED (d) None of these Q. 22 Which of the following is not the method of handling window event? (a) void windowClosed(WindowEvent we) (b) void windowClosing(WindowEvent we) (c) void windowAfterClosing(WindowEvent we) (d) All of these Q. 23 Which method is used to process mouse click? (a) public void mouseClicked(MouseListener m) (b) public void mouseIsClicked(MouseEvent m) (c) public void mouseClicked(MouseEvent m) (d) public void mouseClick(MouseEvent m) Q. 23 Which class is used for this processing method processActionEvent( ) method? (a) Button, List, MenuItem (b) Button,Checkbox,Choice (c) ScrollBar, Component, Button (d) None of the above. Q. 24 Which of this 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 Q. 25 Name the method defined in EvenObject class that returns the object generated from the event. (a) getEvent( ) (b) getObject( ) (c) getId( ) (d) getSource( ) Q. 26 Which of these interfaces define a method actionPerformed() (a) ComponentListener (b) ContainerListener (c) ActionListener (d) InputListener Q. 27 Button Control implements following listener interface. (a) ItemListener (b) ActionListener (c) FlowListener (d) Adapter Q. 28 Clicking the closing button on the upper right corner of a frame generates a (n)‐event. (a) ItemEvent (b) WindowEvent (c) MouseMotionEvent (d) ComponentEvent Q. 29 Which of the following method must be overridden in the order to handle KeyEvent. (a) keyPressed(KeyEvent obj) (b) KeyReleased(KeyEvent obj) (c) KeyTyped(KeyEvent obj) (d) All of these Q. 30 Which of these methods can be used to know the degree of adjustment made by the user? (a) getValue( ) (b) getAdjustmentType( ) (c) getAdjustmentValue( ) (d) getAdjustmentAmount( ) Q. 31 MouseEvent is subclass of which of the following class? (a) ComponentEvent (b) ContainerEvent (c) ItemEvent (d) InputEvent Q. 32 The is an object that is notified when an event occurs. (a) Listener (b) Sources (c) Event (d) None of the above Q. 33 What is the use of String getActionCommand( ) method of ActionEvent class? (a) to obtain the label (caption) of Button (b) to obtain the reference of Button (c) to obtain object of Button (d) to obtain the label (caption) and object of Button Q. 34. Draw the proper output for following code Import java.awt.*; import java.applet.*; public class list2 extends Applet { public void init() { List l= new List(2,true); l.add("java" ); l.add("c++"); l.add("kkk"); add(l); } } Draw Output Here: Q. 35. Write a Programme for Following Output and Conclude. Q. 36. Write proper code for given output Q. 37. Write proper code for given output:

Use Quizgecko on...
Browser
Browser