Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q481: What does the getName() method of the Cookie class return?
- A: The name of the cookie
- B: The value of the cookie
- C: The creation date of the cookie
- D: The expiry date of the cookie
View Answer
A
Q482: In the context of session tracking, what does URL rewriting involve?
- A: Modifying cookie attributes
- B: Appending session data to the URL
- C: Encrypting session data
- D: Deleting cookies from the server
View Answer
B
Q483: Which Java class is used to handle HTTP requests and responses?
- A: HttpServletRequest
- B: HttpServletResponse
- C: HttpServlet
- D: HttpRequest
View Answer
C
Q484: What is the purpose of response.addCookie(c) in Java servlets?
- A: To delete a cookie from the client
- B: To create and send a new cookie to the client
- C: To read cookies sent by the client
- D: To update cookie attributes
View Answer
B
Q485: How can a servlet check if a specific cookie is present?
- A: By inspecting the HTTP headers
- B: By querying the database
- C: By examining the URL
- D: By analyzing the session ID
View Answer
A
Q486: What is URL rewriting used for in session tracking?
- A: Storing user credentials
- B: Maintaining session information
- C: Enhancing page load speed
- D: Encrypting data
View Answer
B
Q487: Which of the following is a disadvantage of URL rewriting?
- A: Persistent state information
- B: Limited to HTTP GET requests
- C: Minimal computational cost
- D: High security
View Answer
B
Q488: In URL rewriting, how is session information typically passed?
- A: In query strings
- B: In cookies
- C: In hidden form fields
- D: In HTTP headers
View Answer
A
Q489: What does the getSession(true) method return in the HttpSession API?
- A: A new session if one does not exist
- B: Null if no session exists
- C: A session only if it is active
- D: The current session without creating a new one
View Answer
A
Q490: How do you store a value in a session object using the HttpSession API?
- A: session.storeAttribute("key", value)
- B: session.put("key", value)
- C: session.setAttribute("key", value)
- D: session.addAttribute("key", value)
View Answer
C