Assignment 9
Assignment 9
QUESTION 1:
Which of the following is/are correct regarding events in Java?
a. EventObject is super class of all the events.
b. AdjustmentEvent will be notified if scroll bar is manipulated.
c. All the classes and methods required for even handling in Java is in java.io package.
d. getID( ) method can be used to determine the name of an event.
Correct Answer: a, b
Detailed Solution:
EventObject class is a super class of all the events and is defined in java.util package.
AdjustmentEvent is generated when a scroll bar is manipulated. All the classes and methods
required for even handling in Java is in java.awt package. The method getID( )is used to determine
the type of event.
_________________________________________________________________________
QUESTION 2:
Which of the following classes is used to display a message dialog in Java Swing?
a. JOptionPane
b. JDialog
c. JMessageDialog
d. JFrame
Correct Answer: a
Detailed Solution:
QUESTION 3:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
Which of the following event is occurred when a button is pressed, a list item is double-
clicked or a menu item is selected?
a. AdjustmentEvent
b. ActionEvent
c. ContainerEvent
d. ComponentEvent
Correct Answer: b
Detailed Solution:
ActionEvent is generated when a button is pressed, a list item is double-clicked or a menu item is
selected.
QUESTION 4:
Which of the statements are correct about Swing programming?
a. AWT is a heavyweight programming.
b. Swing is heavyweight programming.
c. Swing is lightweight programming.
d. Both AWT and Swing are lightweight programming.
Correct Answer: c
Detailed Solution:
___________________________________________________________________________
QUESTION 5:
Event class is defined in which of the following libraries?
a. java.io
b. java.lang
c. java.net
d. java.util
Correct Answer: d
Detailed Solution:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
_____________________________________________________________________________
QUESTION 6:
Which of the following is/are class(es) in javax.swing package?
a. BoxLayout
b. MenuElement
c. JComponent
d. Scrollable
Correct Answer: a, c
Detailed Solution:
MenuElement:
Any component that can be placed into a menu should implement this interface.
Scrollable:
An interface that provides information to a scrolling container like JScrollPane.
QUESTION 7:
Which of the following statement(s) is/are true?
Correct Answer: b, c
Detailed Solution:
Swing component frame support Window Listner.
Swing component dialog support Window Listner.
Swing component combobox does not support Window Listner.
Swing component checkbox does not support Window Listner.
_________________________________________________________________________
QUESTION 8:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
A class which implements the ActionListener interface, also it must implement which of the
following methods?
a. void handle( ActionEvent e )
b. void actionPerformed( ActionEvent e )
c. void eventDispatched( AWTEvent e )
d. String getActionCommand( ActionEvent e )
Correct Answer: b
Detailed Solution:
A class which implements the ActionListener interface must implement void actionPerformed(
ActionEvent e ).
_____________________________________________________________________________
QUESTION 9:
When a component is added or removed, which of the following events is generated?
a. ComponentEvent
b. ContainerEvent
c. FocusEvent
d. InputEvent
Correct Answer: b
Detailed Solution:
A ContainerEvent is generated when a component is added to or removed from a container. It has two
integer constants COMPONENT_ADDED & COMPONENT_REMOVED.
___________________________________________________________________________
QUESTION 10:
Which of these packages contains all the event handling interfaces?
a. java.lang
b. java.awt
c. java.awt.event
d. java.event
Correct Answer: c
Detailed Solution:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
______________________________________________________________________
************END************