MCQ Bank
Which of the following techniques is not used for session tracking in web applications?
- A) Serialization
- B) Cookies
- C) URL Rewriting
- D) Hidden form fields
Which of the following is the main idea behind partitioning a web application into layers?
- A) Reduce Decoupling
- B) Increase Decoupling
- C) Increase Coupling
- D) Reduce Coupling
What is URL rewriting in Java web applications?
- A) Manipulating URLs to maintain session state in web applications.
- B) Encoding special characters in URLs for secure communication.
- C) Rewriting URLs to make them more user-friendly.
- D) Modifying the URL of a web page for search engine optimization.
HttpServletResponse provides ________ methods to perform encoding in java.
- A) Three
- B) One
- C) Two
- D) Four
What is the data type of the config variable in JSP?
- A) ServletContext
- B) ServletConfig
- C) HttpSession
- D) String
The method "cookie.setMaxAge(12)" indicates that the cookie will expire after ___________ .
- A) 12 Seconds
- B) 12 Minutes
- C) 12 Days
- D) 12 Hours
Each web application has ______________ servlet context/s.
- A) 0
- B) 1
- C) 2
- D) 3
Servlet context stores initialization parameters of ______________ .
- A) a java file
- B) of entire web application
- C) one servlet
- D) of all web applications in a server
Which of the following methods of HTTPServletResponse returns the enumeration of all available header names that are contained in the request.
- A) getRequestURL()
- B) getProtocol()
- C) getMethod()
- D) getHeaderNames()
Which file extension is used for JSP files?
- A) .java
- B) .html
- C) .js
- D) .jsp
addCookie() method of HTTPServletResponse takes ___________ as a parameter and adds it to the cookie header.
- A) MAC address
- B) cookie object
- C) session id
- D) ip address
Which of the following is the correct format of writing a page directive in JSP?
- A) <%! page {attribute=”val”} %>
- B) <%$ page {attribute=”val”} %>
- C) <%@ page {attribute=”val”} %>
- D) <%# page {attribute=”val”} %>
Engine of the servlet is ______________ method.
- A) load()
- B) init()
- C) create()
- D) service()
HTML comments are ____________ in browser and JSP comments are ________________ in browser.
- A) shown, shown
- B) hidden, hidden
- C) shown, hidden
- D) hidden, shown
What does request.getCookies() return in Java servlets?
- A) An array of Cookie objects representing cookies sent by the client in the request.
- B) The expiration time of cookies sent by the client.
- C) The number of cookies sent by the client.
- D) A single Cookie object representing all cookies sent by the client.
Which of the following is the correct method of HttpServletResponse to perform encoding in java?
- A) String RedirectURL(String URL)
- B) String encodeMineURL(String URL)
- C) String encodeRedirect(String URL)
- D) String encodeRedirectURL(String URL)
JSP Stands for ____________ .
- A) JavaServer Pages
- B) Java Servlet Pages
- C) Java Server Program
- D) Java Standard Protocol
How does JSP differ from servlets?
- A) JSP is written in Java, while servlets are written in JavaScript.
- B) JSP is executed on the server and generates dynamic content, while servlets handle requests and responses.
- C) JSP is used for client-side interactions, while servlets handle server-side operations.
- D) JSP allows for a mixture of HTML and Java code, while servlets are purely Java code.
What is the purpose of the <servlet-mapping> tag in web.xml?
- A) To configure servlet initialization parameters.
- B) To define servlets with their class names.
- C) To set session configuration for servlets.
- D) To specify the URL patterns that map to servlets.
Which directive is used to import Java classes in JSP?
- A) <%-- --%>
- B) <include>
- C) <scriptlet>
- D) <import>