Tag: science & technology

Questions Related to science & technology

Multiple choice general knowledge science & technology
  1. close

  2. init

  3. destroy

  4. service

Reveal answer Fill a bubble to check yourself
B,C,D Correct answer
Explanation

The servlet lifecycle has three core methods defined in the Servlet interface: init() (called once during initialization), service() (called for each request to process client requests), and destroy() (called once before removal). These methods manage the servlet's creation, request handling, and cleanup. The close() method is not part of the standard servlet API.

Multiple choice general knowledge science & technology
  1. javax.http

  2. jaxax.http.servlet

  3. javax.servlet.http

  4. javax.servlet

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

GenericServlet is an abstract class in the javax.servlet package that implements the Servlet interface and provides basic functionality for protocol-independent servlets. It serves as the foundation for HttpServlet, which is in javax.servlet.http and handles HTTP-specific operations. The package javax.http does not exist in Java EE.

Multiple choice general knowledge science & technology
  1. SinglethreadModel

  2. SingleThreadedModel

  3. SingleThreadModel

  4. SingleThreadmodel

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The SingleThreadModel interface in the Servlet API ensures thread safety by guaranteeing that the servlet handles only one request at a time. The servlet container either serializes requests through the servlet or maintains a pool of servlet instances. Options A, B, and D have incorrect spelling/casing - the actual interface name is SingleThreadModel (with capital T, capital M, no 'ed').

Multiple choice general knowledge science & technology
  1. NullPointerException

  2. ServletException

  3. FileNotFoundException

  4. IOException

  5. none of the above

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

The doGet() method in HttpServlet explicitly declares ServletException and IOException in its method signature. ServletException is thrown for servlet-specific errors, while IOException handles general I/O errors during request processing. NullPointerException (unchecked) and FileNotFoundException (not thrown by doGet) are not declared exceptions.

Multiple choice general knowledge science & technology
  1. User clicks the hyperlink

  2. user submits a form with method=POST

  3. user types the url in the browsers address field and press enter

  4. user submits a form with method=GET

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

GET requests are generated by clicking hyperlinks, typing URLs in the browser address bar, and submitting forms with method=GET. Form submission with method=POST generates a POST request, not GET. These are the standard HTTP methods for different user interactions.

Multiple choice general knowledge science & technology
  1. Getparameter()

  2. getParameterValue()

  3. getParameterValues()

  4. getParamValues()

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The getParameterValues() method returns all values for a parameter that has multiple values (like multi-select dropdowns or checkbox groups). It returns a String array containing all values. getParameter() returns only the first value, while getParameterValue() and getParamValues() are not standard servlet API methods.

Multiple choice general knowledge science & technology
  1. Servlet

  2. ServletContext

  3. ServletConfig

  4. ServletInit

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ServletConfig provides access to a servlet's initialization parameters defined in web.xml using getInitParameter(). ServletContext is for application-wide parameters (accessed via context-param), Servlet is the base interface, and ServletInit is not a valid interface. Each servlet gets its own ServletConfig object during initialization.