Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Chapter: 20
Q321:
In the HelloApplet example, which class is extended to create the applet?
A. JPanel
B. JFrame
C. JApplet
D. Applet
Correct Answer:
C
Chapter: 20
Q322:
How does the start() method function in an applet?
A. Initializes the applet
B. Begins the applet's execution
C. Paints the applet's graphics
D. Performs final cleanup
Correct Answer:
B
Chapter: 20
Q323:
What is the purpose of the destroy() method in the applet life cycle?
A. To clear the screen
B. To perform final cleanup
C. To initialize resources
D. To start the applet
Correct Answer:
B
Chapter: 20
Q324:
How many times does the paint() method execute in the JavaAnim class before clearing the screen?
A. 5
B. 10
C. 20
D. 50
Correct Answer:
B
Chapter: 20
Q325:
What does the chooseColor() method do in the JavaAnim class?
A. Chooses a random font
B. Generates a random color
C. Draws the string "java"
D. Sets the background color
Correct Answer:
B
Chapter: 20
Q326:
Which method is used to randomly select a font in the JavaAnim class?
A. chooseFont()
B. chooseColor()
C. drawJava()
D. init()
Correct Answer:
A
Chapter: 20
Q327:
What is the primary function of the drawJava() method in the JavaAnim class?
A. Draws "java" at random locations
B. Clears the screen
C. Initializes the applet
D. Sets the font and color
Correct Answer:
A
Chapter: 21
Q328:
How can you execute an applet using the appletviewer command?
A. By compiling it with Java
B. By running it from the command line
C. By embedding it in HTML
D. By using a Java IDE
Correct Answer:
B
Chapter: 21
Q329:
What happens if the clearCounter variable reaches 10 in the JavaAnim class?
A. The applet stops executing
B. The screen is cleared
C. The applet initializes
D. The color is changed
Correct Answer:
B
Chapter: 21
Q330:
In the AppletDemo class, which method is called last in the applet life cycle?
A. init()
B. paint()
C. start()
D. destroy()
Correct Answer:
D
Chapter: 21
Q331:
What is a socket in the context of network communication?
A. A device for network access
B. A bi-directional communication channel
C. A file storage unit
D. A protocol for data transfer
Correct Answer:
B
Chapter: 21
Q332:
How many ports are available for TCP and UDP sockets combined?
A. 64k
B. 128k
C. 256k
D. 512k
Correct Answer:
B
Chapter: 21
Q333:
What does a server socket do?
A. Processes data from clients
B. Listens for incoming client connections
C. Connects to other servers
D. Sends data to clients
Correct Answer:
B
Chapter: 21
Q334:
What is the purpose of the client’s socket?
A. To listen for incoming connections
B. To process client requests
C. To communicate with the server
D. To handle data storage
Correct Answer:
C
Chapter: 21
Q335:
What Java packages are required for socket programming?
A. java.net., java.io.
B. java.awt., java.swing.
C. java.util., java.math.
D. java.lang., java.sql.
Correct Answer:
A
Chapter: 21
Q336:
Which method is used to create a server socket in Java?
A. ServerSocket()
B. Socket()
C. Connect()
D. Listen()
Correct Answer:
A
Chapter: 21
Q337:
What does the accept() method in a server socket do?
A. Creates a new client socket
B. Listens for client requests
C. Establishes a connection with the server
D. Closes the server socket
Correct Answer:
A
Chapter: 22
Q338:
How do you send a message from a client to a server in Java socket programming?
A. Using pw.println()
B. Using pw.readLine()
C. Using s.getInputStream()
D. Using s.getOutputStream()
Correct Answer:
A
Chapter: 22
Q339:
What is the purpose of the s.close() method in socket programming?
A. To close the server socket
B. To close the client socket
C. To flush the output stream
D. To terminate the connection
Correct Answer:
B
Chapter: 22
Q340:
Which of the following is a well-known port number?
A. 21
B. 8080
C. 3306
D. 9000
Correct Answer:
A