CHAPTER 2 :Event Handling(20 Marks) ADVANCED JAVA PROGRAMMING MCQ I Scheme


CHAPTER 2 :Event Handling(20 Marks)


Q.1 ______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.2 What is an event is delegation event model used by Java programming    Language?
   (a)An event is an object that describes a state change in a source.
(b)  An event is an object that describes a state change in a processing.
(c)   An event is an object that describes any change by the user and
    System
   (d)An event is a class used for defining object, to create events.

Q. 3 method are used to register a keyboard event listener.  
(a) KeyListenerO     (b) addKistenerO 
(c) addKeyListenerO  (d) eventKeyboardListenerO 

Q.4 _____ method are used to register a mouse motion  listener. 
(a)   addMouseO 
(b)  addMouseListenerO 
(c)   addMouseMotionListnerO 
(d)  eventMouseMotionListenerO  

Q.5 What is a listener in context to event handling?  
(a) A listener is a variable that is notified when an event   occurs. 
(b)  A listener is a 'object that is notified when an event   occurs. 
(c)   A listener is a method that is notified when an event   occurs. 
(d)  None of the mentioned  


Q. 6 In which library event class is defined ? 
  (a) java.io     (b) java.util 
  (c) java.lang   (d) java.net  


Q. 7 Which of these methods can be used to determine the type of event ? 
  (a) getSoureeO   (b) getEventO 
  (c) getIDO       (d) getEventObjeetO  

Q.8 ____ is super class of all the events. 
 (a) EventObjeet   (b) EventClass 
 (c) AetionEvent   (d) ItemEvent  

Q. 9 If scroll bar is manipulated______  event will be notified. 
 (a) AetionEvent        (b) ComponentEvent 
 (c) AdjustmentEvent     (d) WindowEvent


Q.10 if we close an applet's window generated. ___ event will be 
 (a) ActionEvent      (b) ComponentEvent 
 (c) AdjustmentEvent  (d)WindowEvent

Q. 11 Which of these events is generated when a button is pressed? 
  (a) ActionEvent     (b) KeyEvent 
  (c) Window Event   (d) AdjustmentEvent  




Q. 12 __ method can be used to obtain the command name for invoking     ActionEvent object. 
  (a) getCommand()     (b) getActionCommand()
  (c) getActionEvent()   (d) getActionEventCommand() 

Q. 13 Which of these are integer constants defined in ActionEvent class? 
  (a) ALT_MASK      (b) CTRL_MASK
  (c) SHIFT_MASK    (d) All ofthe mentioned  

Q.14.Which of these methods can be used to determine type of Event
(a)getID()          (b)getSource()
(c ) getEvent()       (d) getEventObject()

Q. 15 _____ method can be used to determine the type of adjustment event. 
   (a) getType()              (b) getEventType() 
   (c) getAdjustmentType()  (d) getEventObjectType()  

Q. 16 __ method can be used to know the degree of adjustment made by the user. 
    (a) getValue()            (b) getAdjustmentType()
   (c) getAdjustmentValue()  (d) getAdjustmentAmount()

Q.17.What are the KeyListener Interface? (a) keyPressed    (b) keyReleased (c ) keyTyped     (d) All three.

Q. 18 Which of these constant value will change when the button at the end of scroll    bar was clicked to increase its value? 
(a)   BLOCK_DECREMENT  
(b)  BLOCK_INCREMENT  
(c)   UNIT_DECREMENT  
(d)  UNIT_INCREMENT  


Q.19 When the size of component is changed, __ event is generated. 
  (a) ComponentEvent (b) ContainerEvent
  (c) FocusEvent     (d) InputEvent

Q. 20 When the component is added or removed ? Which of these events is  generated ? 
   (a) ComponentEvent (b) ContainerEvent  
   (c) FocusEvent    (d) InputEvent 



Q. 21  method can be used to obtain the reference to the container that  generated a ContainerEvent. 
   (a) getContainerO  (b) getContainerCommandO 
   (c) getActionEventO   (d) getContainerEventO  

Q.22.Which is the constant used for always providing the vertical scrollbar
(a) VERTICAL_SCROLLBAR_ALWAYS        
(B)VERTICAL _SCROLLBAR_AS_NEEDED
Ans:b

Q23.Which is the method used for WindowsClosing Event?
(a)windowOpened()      (b)windowClosed()
(c ) windowClosing()    (d) windowDeactivated()

Q.24_____event is generated when computer gains or losses input focus. 
  (a) ComponentEvent (b) ContainerEvent  
  (c) FocusEvent     (d) InputEvent  

 Q.25 FocusEvent is subclass of which of these classes? 
  (a) ComponentEvent (b) ContainerEvent  
  (c) ItemEvent      (d) InputEvent 

Q.26 ___ can be used to know the type of focus change. 
   (a) typeFocus()    (b) typeEventFocus()
   (c) isTemporary()  (d) isPermanent()

Q.27____ is superclass of Container Event class. 
    (a) WindowEvent  (b) ComponentEvent
    (c) ItemEvent    (d) InputEvent

Q.28 Which of the following method can be used to obtain the coordinates   of a mouse?  
  (a) getPoint()     (b) getCoordinates()
  (c) getMouseXY()  (d) getMouseCordinates()

Q.29_____method can be used to change location of an event. 
  (a) ChangePoint()    (b) TranslatePoint()
  (c) ChangeCordinates()  (d) TranslateCordinates()  


Q.30 Which of the following is integer constants of TextEvent class? 
(a)   TEXT_CHANGED  
(b)  TEXT_FORMAT_CHANGED  
(c)   TEXT_ VALUE_CHANGED  
(d)  TEXT_SIZE_CHANGED  
  
Q. 31_____ is used to obtain the object that generated a Window Event. 
  (a) getMethod()      (b) getWindow()  
  (c) getWindowEvent()  (d) getWindowObject()  

Q.32 MouseEvent is subclass of which of these classes? 
  (a) ComponentEvent (b) ContainerEvent 
  (c) ItemEvent      (d) InputEvent 

Q.33 ___ method is used to get x coordinate of the mouse. 
  (a) getXO         (b) getXCoordinateO
  (c) getCoordinateXO (d) getPointXO


Q.34 Which of these are constants defined in WindowEvent class? 
(a)   WINDOW_ACTIVATED  
(b)  WINDOW_CLOSED 
(c)   WINDOW _DEICONIFIED  
(d)  All of the mentioned 


Q. 35 ____ is superclass of Window Event class. 
  (a) WindowEvent  (b) ComponentEvent
  (c) ItemEvent    (d) InputEvent

Q.36 Which of these packages contains all the event handling interfaces? 
   (a) java.lang      (b) java.awt
   (c) java.awt.event  (d) java.event

Q.37 When a component is added to a container which of these interfaces handles   the event? 
  (a) ComponentListener  (b) ContainerListener
  (c) FocusListener      (d) InputListener

Q. 38 ___ interface define a method actionPerformed(). 
  (a) ComponentListener (b) ContainerListener  
   (c) ActionListener    (d) InputListener

Q.39.Which method is used to set an icon to an Label?
(a) setIcon()     (b)setImage()
(c) getImage()    (d)setIconImage()

Q. 40 __ interfaces define a method itemStateChanged()
   (a) ComponentListner  (b)ContainerListener
   (c) ActionListener      (d) ItemListener

Q.41 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  

Q. 42_____ methods will be invoked if a charaeter is entered. 
    (a) keyPressed()   (b) keyReleased()
    (c) keyTyped()    (d) keyEntered()

Q.43_____methods is defined in MouseMotionAdapter class.
   (a) mouseDragged()     (b) mousePressed()
   (c) mouseReleased()     (d)mouseClicked() Q.44.Which method is used to have rollover icon?
(a)setDisabledIcon()           (b)setDisabled()
(c) setRollover()              (d)setRolloverIcon()

Q.45_______is the superclass of all Adapter classes.
   (a) Applet     (b) ComponentEvent
   (c) Event      (d) InputEvent

Q.46 In Java, events are all the activities that occur between:
  (a)The user        (b) The application
  (c) Both (a) and (b)  (d) None of the above

Q.47 EventObject class belongs to:
   (a) java.util      (b) java.awt
   (c) java.lang     (d) java.sql
Q.48 The Component class is an abstract class and so its_______are used     to create components.
    (a) Subclasses       (b)Superclasses     (c)Both (a) and (b)    (d)None of these.

Q.49 The AWT classes can be roughly categorized into the following groups:
   (a)GUI component    (b)Layouts
   (c) Graphics tools     (d)All of these

Q.50 Window is used for________windows.
   (a)Creating      (b) Handling
   (c) Modifying     (d) Both (a) and (b)

Q.51 The_______interface is used to handle the menu events.
   (a) ContainerListener     (b) FocusListener
   (c) ActionListener        (d) WindowListner

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

Q.53 The name of the event classes are:
(a)   ActionEvent, ComponentEvent
(b)  ContainerEvent, FocusEvent
(c)   ItemEvevt, KeyEvent
(d)  All of these

Q.54 Java packages such as_____ support the Event handling mechanism. 
  (a) Java.util        (b) Java.awt
  (c) Java.awt.event   (d) All of these

Q. 55 An event is generated when the internal state of the event source is_____ 
  (a) Not changed         (b) Changed 
  (c) Either changed or not  (d) None of these.  

Q. 56 The_____ interface handles list events: 
  (a) ContainerListener  (b) ItemListener
  (c) FocusListener     (d) ActionListener

Q. 57 Which of the following are true? 
(a)   The event-inheritance model has replaced the event-    delegation model. 
(b)  The event-inheritance model is more efficient than the    event-delegation model. 
(c)   The Event Delegation Model uses event listeners to define the methods of event Handling    classes
(d)  The event delegation model uses handleEvent() method to support event handling.

Q. 58  Which of the following is the highest class in the event- delegation model ?    
(a) java.util.EventListener  
(b)  java.util.EventObject  
(c)   java.awt.A WTEvent 
(d)  java.awt.event.A WTEvent

Q. 59 When two or more objects are added as. listeners for the same event,    which listener is first invoked to handle the event? 
(a)  The first object that was added as listener.  
(b)  The last object that was added as listener.    (c) There is no way to determine which listener will be    invoked first. 
  (d) It is impossible to have more than one listener for a    given event. 

Q. 60 Which ofthe following are true? 
(a)   A TextField object may generate an ActionEvent.  
(b)  A Button object may generate an ActionEvent.  
(c)   A MenuItem object may generate an ActionEvent.  
(d)  All of above 

Q. 61  Which of the following are true? 
(a)   The MouseListener interface defines methods for   handling mouse clicks. 
(b)  The MouseMotionListener interface defines methods   for handling mouse clicks. 
(c)   The ActionListener interface defines methods for   handling the clicking of a button. 
(d)  Option (a) and (c) 

Q. 62  Suppose that you want to have an object "eh" to handle the  TextEvent of a TextArea object. How should you add eh as the event  handler to it ? 
  (a) t.addTextListener(eh);   (b) eh.addTextListener(t);
  (c) addTextListener(eh.t);   (d) addTextListener(t,eh); 


Q. 63 What is the preferred way to handle an object's events in Java 2?  
(a) Override the object's handleEvent( ) method. 
 (b) Add one or more event listeners to handle the events.   
(c) Have the object override its processEvent() methods  
(d) Have the object override its dispatchEvent() methods.

Q. 64  Which of the following are true? 
(a)   A component may handle its own events by adding   itself as an event listener. 
(b)  A component may handle its own events by overriding   its event-dispatching method. 
(c)   A component may not handle its own events.  
(d)  Option (a) and (b) 

Q. 65  The event delegation model, introduced in release 1.1 ofthe  JDK, is fully compatible with the event model. 
 (a) True           (b) False 


Q. 66 A component subclass that has executed enableEvents( ) to  enable processing of a certain kind of event cannot also use  an adapter as a listener for the same kind of event. 
  (a) True  (b) False 













   

Comments