Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q311: In the AnimTest class, what does the Timer object do?
- A: It handles mouse events
- B: It schedules repeated calls to actionPerformed()
- C: It changes the size of the JFrame
- D: It updates the ball's color
View Answer
B
Q312: What does the if (p.mX == 0) condition check in the actionPerformed method?
- A: If the ball has reached the minimum width of the frame
- B: If the ball is moving in the opposite direction
- C: If the ball should change color
- D: If the ball's position is within the frame's boundaries
View Answer
A
Q313: How does p.repaint() affect the ball animation?
- A: It clears the ball from the screen
- B: It updates the ball's position on the screen
- C: It stops the ball's movement
- D: It changes the ball's color
View Answer
B
Q314: Which Swing method is recommended for custom painting rather than calling paintComponent() directly?
- A: repaint()
- B: paint()
- C: paintBorder()
- D: paintChildren()
View Answer
A
Q315: How is mouse dragging handled in the provided example?
- A: By overriding the paintComponent() method
- B: By using the MouseMotionAdapter to capture drag events
- C: By calling super.paintComponent()
- D: By setting the position manually
View Answer
B
Q316: What happens when the if (f.getWidth()-40 == p.mX) condition is true in the actionPerformed method?
- A: The X-direction of the ball changes
- B: The ball is drawn at the top-left corner
- C: The ball's size is increased
- D: The Timer is stopped
View Answer
A
Q317: What is an applet in Java?
- A: A standalone application
- B: A small program embedded in a web page
- C: A type of Java class
- D: A database application
View Answer
B
Q318: Which method initializes an applet when it is loaded?
- A: start()
- B: paint()
- C: init()
- D: destroy()
View Answer
C
Q319: What is the purpose of the paint() method in an applet?
- A: To stop the applet's execution
- B: To perform final cleanup
- C: To draw or display content
- D: To initialize the applet
View Answer
C
Q320: How can you view an applet without using a browser?
- A: By running it directly in Java IDE
- B: By using the appletviewer command
- C: By compiling it to a .class file
- D: By using an external tool
View Answer
B