Home / CSE MCQs / Servlets-1 ::

CSE MCQs :: Servlets-1

  1. Which of the following code is used to get an attribute in a HTTP Session object in servlets?
  2. A.
    session.getAttribute(String name)
    B.
    session.alterAttribute(String name)
    C.
    session.updateAttribute(String name)
    D.
    session.setAttribute(String name)

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which method is used to specify before any lines that uses the PintWriter?
  4. A.
    setPageType()
    B.
    setContextType()
    C.
    setContentType()
    D.
    setResponseType()

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What are the functions of Servlet container?
  6. A.
    Lifecycle management
    B.
    Communication support
    C.
    Multithreading support
    D.
    All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is bytecode?
  8. A.
    Machine-specific code
    B.
    Java code
    C.
    Machine-independent code
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which object of HttpSession can be used to view and manipulate information about a session?
  10. A.
    session identifier
    B.
    creation time
    C.
    last accessed time
    D.
    All mentioned above

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following is true about servlets?
  12. A.
    Servlets execute within the address space of web server
    B.
    Servlets are platform-independent because they are written in java
    C.
    Servlets can use the full functionality of the Java class libraries
    D.
    Servlets execute within the address space of web server, platform independent and uses the functionality of java class libraries

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following statements are correct about the status of the Http response.
  14. A.
    A status of 200 to 299 signifies that the request was successful
    B.
    A status of 300 to 399 are informational messages
    C.
    A status of 400 to 499 indicates an error in the server
    D.
    A status of 500 to 599 indicates an error in the client

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which JDBC driver Type(s) can be used in either applet or servlet code?
  16. A.
    Both Type 1 and Type 2
    B.
    Both Type 1 and Type 3
    C.
    Both Type 3 and Type 4
    D.
    Type 4 only

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following code retrieves the MIME type of the body of the request?
  18. A.
    new MimeType()
    B.
    request.getContentType()
    C.
    response.getContentType()
    D.
    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which methods are used to bind the objects on HttpSession instance and get the objects?
  20. A.
    setAttribute
    B.
    getAttribute
    C.
    Both A & B
    D.
    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum