Monday 18 May 2020

AsCEnD Java MVC and Web Development

Java MVC and Web Development Assessment


Q1. Select all options which are true about the welcome-file-list

Answer: When the only specified item is welcome.html, the server still treats index.html as a backup
        lf not specified the default landing page is index html

Q2. GenericServlet class is encapsulated inside ____ package?

Answer: javax.servlet

Q3. Which method is used to retrieve a form value in a JSP or Servlet?

Answer: request.getParameter(String)

Q4. When doPost() method of servlet gets called?

Answer: Both of the above

Q5. Which class provide implementation for service() method ?

Answer: HttpServlet

Q6. The _____ object is used to forward the request processing from one servlet to another?

Answer: RequestDispatcher

Q7. When init() method of servlet gets called?

Answer: The init() method is called when the servlet is first created.

Q8. Given request is an HttpServletRequest, which code snippets will creates a session if one doesn't exist?

Answer: request getSession();

Q9. Which of the following attribute is used to have uncaught run-time exceptions automatically forwarded to an error processing page?

Answer: errorPage

Q10. What file specifies the default welcome page?

Answer: Web.xml

Q11. Which method of HttpServletResponse is used to redirect an HTTP request to another URL ?

Answer: sendRedirect()

Q12. Which of the following code is used to get a HTTP Session object in servlets?

Answer: request.getSession()

Q13. How do you switch between Java code and HTML code in a jsp file?

Answer: Java code is the default HTML code is kept inside <%> brackets.

Q14. What is javax.servlet.http.HttpServlet?

Answer: abstract class

Q15. JSP pages are processed on the server

Answer: TRUE

Q16. What are the different techniques for managing a session?

Answer: All of the above

Q17. what is the return type of getAttribute(String name) in ServletRequest

Answer: String

Q18. Which of the below methods returns a string containing information about the serviet, such as its author, version, and copyrigh.

Answer: getServletinfo()

Q19. Which of the following attribute is used to mark a page as error processing page?

Answer: isErrorPage

Q20. Which of the following statement is not correct about HTTP method ?

Answer: A POST request append data to the end of the URL

Q21. session is instance of which class?

Answer: HttpSession

Q22. Choose the statement that best describes the relationship between JSP and servlets:

Answer: Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage

Q23. Which tag in the jsp is used to define a page as an error page?

Answer: <%@page isErrorPage="true" %>

Q24. Which of these classes define the getWriter() method that returns an object of type PrintWriter ?

Answer: HttpServletResponse

Q25. Consider the following JSP page with an error in the Java code. What will happen when we try to access this jsp file on the server

Answer: The page will load normally, and the java errors which happen will be skipped.

Q26. Which of the following is not a implicit object?

Answer: cookie

Q27. Get is faster than POST method

Answer: TRUE

Q28. Which of the following is true about Initialization phase in JSP life cycle?

Answer: When a container loads a JSP it invokes the jsplnit() method before servicing any requests

Q29. The servlet-mapping element defines

Answer: a mapping between a servlet and a URL pattern

Q30. If in a form tag, no method attribute is specified, what function will be run?

Answer: doGet

4 comments: