J2EE MCQ with Answers
This collection of Java Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “J2EE”.
1. What exception is thrown when Servlet initialization fails?
A ServletException
B RemoteException
C IOException
D SocketException
2. The classes in the _________ directory must be available for the “Classloader” of the application?
A /root/lib/classes/
B /root/classes/
C /WEB-INF/lib/classes/
D /WEB-INF/classes/
3. Which of the following statements are correct about the status of the Http response?
A HTTP status codes in the 500 to 599 range indicate that the error is related to the client
B HTTP status codes in the 400 to 499 range indicate that the error is related to the server
C HTTP status codes in the 300 to 399 range are informational messages.
D HTTP status codes in the 200 to 299 range means that the client’s request was successful.
4. Why are beans used in the J2EE architecture instead of writing all the code in the JSPs?
A Allows the separation of roles between web developers and application developers
B Allows integration with Content Management tools
5. What is correct about JSP Scriptlets ?
A A loop can start in one Scriptlet and end in another
B Instructions in a Scriptlet must follow Java syntax
C Semicolon is required at the end of each statement in a Scriptlet
D All the answers are true
6. Which method is called first each time a servlet is called?
A Start()
B Run()
C init()
D Servive()
7. What is the scope of response object?
A session
B page
C request
D response
8. In JSP, how can you tell which HTTP method (GET or POST) is being used by the client request?
A Using request.getMethod()
B Using request.setMethod()
C Impossible to know
9. What is the difference between using “forward” and “sendRedirect()”?
A forward runs on the client side while sendRedirect() runs on the server side.
B forward runs on the server side while sendRedirect() runs on the client side.
C Both methods work in the same way.
10. How can a servlet call a JSP error page?
A This feature is not supported
B When the servlet throws the exception, it will be automatically caught by the calling JSP page
C The servlet should forward the request to the URL of the specific error page. The exception is thrown as an attribute named “javax.servlet.jsp.jspException”
D The servlet should redirect the response to the error page
11. Any client request to access resources in the WEB-INF/ directory must be returned with a ________?
A BAD_REQUEST
B SC_NOT_FOUND
C SC_INTERNAL_SERVER_ERROR
D ESC_BAD_REQUEST
12. Which of the following is not an implicit object in JSP?
A system
B page
C response
D request