Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q191: What does the mouseDragged method of MouseMotionListener handle?
- A: Mouse movements without dragging
- B: Mouse movements while dragging
- C: Mouse button clicks
- D: Mouse entering or exiting component boundaries
View Answer
B
Q192: What method should be implemented when a class implements MouseListener?
- A: mouseMoved(MouseEvent me)
- B: mouseDragged(MouseEvent me)
- C: mousePressed(MouseEvent me)
- D: mouseReleased(MouseEvent me)
View Answer
C
Q193: Which method of MouseListener is called when a mouse button is clicked?
- A: mouseEntered(MouseEvent me)
- B: mouseClicked(MouseEvent me)
- C: mousePressed(MouseEvent me)
- D: mouseReleased(MouseEvent me)
View Answer
B
Q194: How do you register a mouse event handler with a JFrame?
- A: frame.addMouseMotionListener(this);
- B: frame.addMouseListener(this);
- C: frame.addMouseEventHandler(this);
- D: frame.registerMouseHandler(this);
View Answer
A
Q195: What is the role of windowClosing method in the WindowListener interface?
- A: To handle the event when the window is activated
- B: To handle the event when the window is closing
- C: To handle the event when the window is minimized
- D: To handle the event when the window is closed
View Answer
B
Q196: How can you show a message when a window is about to close?
- A: By setting the frame’s default close operation
- B: By implementing the windowClosing method
- C: By using the JOptionPane.showMessageDialog()
- D: By overriding the windowClosed method
View Answer
B
Q197: What layout manager is used in the provided example?
- A: FlowLayout
- B: BorderLayout
- C: GridLayout
- D: BoxLayout
View Answer
B
Q198: What method is used to display a message dialog in Swing?
- A: showMessageDialog()
- B: displayMessage()
- C: showDialog()
- D: messageDialog()
View Answer
A
Q199: In the EventsEx example, what will be shown in the label when the mouse is moved?
- A: Coordinates of the mouse when dragged
- B: Coordinates of the mouse when moved
- C: Message "Mouse is moved"
- D: The message "Mouse clicked"
View Answer
B
Q200: What method should you use to make a JFrame visible?
- A: setVisible(true)
- B: display()
- C: show()
- D: open()
View Answer
A