Java Swing and Abstract Windowing Toolkit (AWT) MCQs | PROGRAMMING IN JAVA Assignment 9 | NPTEL

Test your Java GUI programming skills with these comprehensive multiple-choice questions on Java Swing and AWT. Learn the fundamentals of creating graphical user interfaces in Java and prepare for exams or interviews


Java Swing and Abstract Windowing Toolkit (AWT) MCQs  PROGRAMMING IN JAVA Assignment 9   NPTEL

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.
Answer

a. EventObject is super class of all the events.,b. AdjustmentEvent will be notified if scroll bar is manipulated.



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.

Which of the following classes is used to display a message dialog in Java Swing?

a. JOptionPane
b. JDialog
c. JMessageDialog
d. JFrame
Answer

a. JOptionPane



JOptionPane is used to display a message dialog in Java Swing.

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
Answer


b. ActionEvent

ActionEvent is generated when a button is pressed, a list item is double-clicked or a menu item is selected.

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.
Answer

c. Swing is lightweight programming.

Swing is lightweight programming.

Event class is defined in which of the following libraries?

a. java.io
b. java.lang
c. java.net
d. java.util
Answer

d. java.util

Event class is defined in java.util library.

Which of the following is/are class(es) in javax.swing package?

a. BoxLayout
b. MenuElement
c. JComponent
d. Scrollable
Answer

a. BoxLayout,c. JComponent

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. All others are Class.

Which of the following statement(s) is/are true?

a. Swing component frame does not support Window Listner.
b. Swing component combobox does not support Window Listner.
c. Swing component checkbox does not support Window Listner.
d. Swing component dialog does not support Window Listner.
Answer

b. Swing component combobox does not support Window Listner.,c. Swing component checkbox does not support Window Listner.

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.

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 )
Answer

b. void actionPerformed( ActionEvent e )

A class which implements the ActionListener interface must implement void actionPerformed( ActionEvent e ).

When a component is added or removed, which of the following events is generated?

a. ComponentEvent
b. ContainerEvent
c. FocusEvent
d. InputEvent
Answer

b. ContainerEvent

A ContainerEvent is generated when a component is added to or removed from a container. It has two integer constants COMPONENT_ADDED and COMPONENT_REMOVED.

Which of these packages contains all the event handling interfaces?

a. java.lang
b. java.awt
c. java.awt.event
d. java.event
Answer

java.awt.event

java.awt.event contains all the event handling interfaces.

PYQ | The Joy of Computing using Python - Course | NPTEL

Learn Java Programming for free with Computer Course - CompEduBox Android app. Share with your Friends

Post a Comment

0 Comments