Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Chapter: 11
Q181:
What will be displayed when the actionPerformed() method is triggered?
A. A message dialog
B. A new frame
C. An updated label
D. A file dialog
Correct Answer:
A
Chapter: 11
Q182:
How do you create a JFrame instance?
A. JFrame frame = new JFrame();
B. JFrame frame = new JFrame("Title");
C. JFrame frame = new JFrame("Title", true);
D. JFrame frame = JFrame();
Correct Answer:
A
Chapter: 11
Q183:
In the given example, what happens when the "+" button is clicked?
A. The sum of two numbers is displayed
B. The product of two numbers is displayed
C. A message dialog appears
D. The text fields are cleared
Correct Answer:
A
Chapter: 11
Q184:
What does the getSource() method of the ActionEvent object return?
A. The event handler
B. The event source
C. The event type
D. The event description
Correct Answer:
B
Chapter: 11
Q185:
How is the JOptionPane.showMessageDialog() method used in the provided code?
A. To show a message dialog when an action is performed
B. To update a text field
C. To create a new button
D. To display an image
Correct Answer:
A
Chapter: 11
Q186:
What layout manager is used in the provided examples?
A. FlowLayout
B. GridLayout
C. BorderLayout
D. BoxLayout
Correct Answer:
A
Chapter: 12
Q187:
In the SmallCalcApp example, what will be shown in the answer field when the "*" button is pressed?
A. The sum of the operands
B. The product of the operands
C. A division result
D. An addition result
Correct Answer:
B
Chapter: 12
Q188:
Which method is used to make a JFrame visible?
A. setVisible(true)
B. show()
C. display()
D. open()
Correct Answer:
A
Chapter: 12
Q189:
What type of event does the WindowEvent class handle?
A. Button click events
B. Window state changes
C. Mouse movements
D. Keyboard inputs
Correct Answer:
B
Chapter: 12
Q190:
Which interface is used for handling mouse motion events?
A. MouseListener
B. MouseMotionListener
C. ActionListener
D. WindowListener
Correct Answer:
B
Chapter: 12
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
Correct Answer:
B
Chapter: 12
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)
Correct Answer:
C
Chapter: 12
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)
Correct Answer:
B
Chapter: 12
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);
Correct Answer:
A
Chapter: 12
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
Correct Answer:
B
Chapter: 12
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
Correct Answer:
B
Chapter: 12
Q197:
What layout manager is used in the provided example?
A. FlowLayout
B. BorderLayout
C. GridLayout
D. BoxLayout
Correct Answer:
B
Chapter: 12
Q198:
What method is used to display a message dialog in Swing?
A. showMessageDialog()
B. displayMessage()
C. showDialog()
D. messageDialog()
Correct Answer:
A
Chapter: 12
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"
Correct Answer:
B
Chapter: 12
Q200:
What method should you use to make a JFrame visible?
A. setVisible(true)
B. display()
C. show()
D. open()
Correct Answer:
A