Learn J2EE MCQs

Prepare J2EE MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of `JSF` in J2EE?

1) Build user interfaces for web applications

2) Manage database transactions

3) Handle HTTP requests

4) Manage asynchronous messaging

Answer : Build user interfaces for web applications

Which method is used to read request headers in a servlet?

1) request.getHeader()

2) response.getHeader()

3) session.getHeader()

4) context.getHeader()

Answer : request.getHeader()

Which of the following technologies is used for creating web services in J2EE?

1) JAX-RS

2) JMS

3) JNDI

4) JDBC

Answer : JAX-RS

Which of the following is a design pattern used in J2EE?

1) Model-View-Controller (MVC)

2) Singleton

3) Factory

4) Builder

Answer : Model-View-Controller (MVC)

Which of the following objects is used to send data to the client in a servlet?

1) HttpServletResponse

2) HttpServletRequest

3) HttpSession

4) ServletContext

Answer : HttpServletResponse

Which method in the `HttpServlet` class handles the HTTP POST requests?

1) doPost()

2) doGet()

3) service()

4) init()

Answer : doPost()

What is the default scope for a JSP page directive?

1) page

2) request

3) session

4) application

Answer : page

Which annotation is used to map a servlet to a URL pattern?

1) @WebServlet

2) @WebListener

3) @Path

4) @EJB

Answer : @WebServlet

What is the purpose of the `@PUT` annotation in RESTful web services?

1) Maps HTTP PUT requests

2) Maps HTTP POST requests

3) Maps HTTP GET requests

4) Maps HTTP DELETE requests

Answer : Maps HTTP PUT requests

Which method in a servlet is used to handle HTTP GET requests?

1) doGet()

2) doPost()

3) doPut()

4) doDelete()

Answer : doGet()