Skip to main content

Web Design and Development MCQs with Answers

Practice important Web Design and Development MCQs with answers and explanations.

Chapter: 12
Q201:
How many methods are there in the WindowListener interface?
A. 5
B. 6
C. 7
D. 8
Correct Answer: C
Chapter: 13
Q202:
What is the main purpose of the initGUI() method in the examples?
A. To initialize the GUI components and layout
B. To handle window events
C. To create new instances of the components
D. To set up event handling listeners
Correct Answer: A
Chapter: 13
Q203:
Event source can have --------- listeners registered on it.
A. Single
B. Double
C. Triple
D. Multiple
Correct Answer: D
Chapter: 13
Q204:
Which interface must a class implement to handle window events?
A. WindowListener
B. WindowEventListener
C. WindowHandler
D. WindowEvents
Correct Answer: A
Chapter: 13
Q205:
What does the getSource() method of the MouseEvent object return?
A. The mouse button pressed
B. The component that generated the event
C. The coordinates of the mouse
D. The type of the mouse event
Correct Answer: B
Chapter: 13
Q206:
What is the purpose of an Adapter class in Java?
A. To provide a default implementation of all methods in an interface
B. To extend functionality of an existing class
C. To handle GUI events without code clutter
D. To create a new interface
Correct Answer: A
Chapter: 13
Q207:
Which adapter class is used for handling window events in Java?
A. WindowAdapter
B. MouseAdapter
C. ActionAdapter
D. KeyAdapter
Correct Answer: A
Chapter: 13
Q208:
In which scenario would you use an anonymous inner class?
A. When an object is used multiple times
B. For one-time use of an object
C. To implement multiple interfaces
D. To avoid inner class complexity
Correct Answer: B
Chapter: 13
Q209:
Which method of the WindowListener interface is used to handle the event of closing a window?
A. windowActivated
B. windowClosing
C. windowDeactivated
D. windowOpened
Correct Answer: B
Chapter: 13
Q210:
How do you handle mouse motion events in Java using adapter classes?
A. By extending MouseMotionAdapter
B. By implementing MouseMotionListener
C. By using MouseAdapter
D. By implementing MouseListener
Correct Answer: A
Chapter: 13
Q211:
Which method needs to be overridden when using WindowAdapter to handle window closing?
A. windowClosed
B. windowClosing
C. windowActivated
D. windowDeactivated
Correct Answer: B
Chapter: 13
Q212:
What does the following code do: frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { JOptionPane.showMessageDialog(null, "Good Bye"); System.exit(0); } });
A. Registers a WindowListener for window closing event
B. Registers an anonymous inner class for window closing
C. Displays a message and exits on window close
D. None of the above
Correct Answer: B
Chapter: 13
Q213:
When handling events in Java, which of the following is NOT a valid approach?
A. Using an anonymous inner class
B. Extending an Adapter class
C. Implementing multiple interfaces in one class
D. Using an inner class
Correct Answer: C
Chapter: 14
Q214:
In the SmallCalcApp example, what operation does the ButtonHandler class perform when the '+' button is pressed?
A. Subtracts two numbers
B. Multiplies two numbers
C. Adds two numbers
D. Divides two numbers
Correct Answer: C
Chapter: 14
Q215:
_______ is the process of converting a java object into Byte stream.
A. Encapsulation
B. Abstraction
C. Serialization
D. None of the above
Correct Answer: C
Chapter: 14
Q216:
Which of these can be used to store the state of an object in a file?
A. FileOutputStream
B. ObjectOutputStream
C. ObjectInputStream
D. FileInputStream
Correct Answer: B
Chapter: 14
Q217:
Which Java class provides empty method implementations for all methods of MouseMotionListener?
A. MouseMotionAdapter
B. MouseAdapter
C. MouseListener
D. MouseEvent
Correct Answer: A
Chapter: 14
Q218:
How can you handle both window and mouse events in a single class while using inner classes?
A. By using multiple inner classes
B. By extending multiple adapter classes
C. By implementing multiple interfaces
D. By using both WindowAdapter and MouseMotionAdapter as inner classes
Correct Answer: D
Chapter: 14
Q219:
What is the purpose of the java.sql package in JDBC?
A. To handle Java GUI components
B. To provide classes and interfaces for database interaction
C. To manage file I/O operations
D. To create graphical user interfaces
Correct Answer: B
Chapter: 14
Q220:
Which JDBC driver is used for connecting to Microsoft Access databases?
A. oracle.jdbc.driver.OracleDriver
B. com.mysql.cj.jdbc.Driver
C. sun.jdbc.odbc.JdbcOdbcDriver
D. org.postgresql.Driver
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Web Design and Development

🚀 Start Quiz Now