Learn J2EE MCQs

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

What is the role of `JMS` in J2EE?

1) Handle asynchronous messaging

2) Process HTTP requests

3) Render dynamic content

4) Manage database connections

Answer : Handle asynchronous messaging

Which tag in `web.xml` is used to define a filter mapping?

1) <filter-mapping>

2) <servlet>

3) <filter>

4) <context-param>

Answer : <filter-mapping>

What is the purpose of `JDBC` in J2EE?

1) Database connectivity

2) Messaging services

3) Session management

4) Transaction management

Answer : Database connectivity

Which of the following is true about a stateful session bean?

1) It maintains state between method calls

2) It handles transactions

3) It is stateless

4) It processes requests asynchronously

Answer : It maintains state between method calls

Which method is used to retrieve form data sent in a `POST` request?

1) request.getParameter()

2) request.getAttribute()

3) session.getAttribute()

4) response.getParameter()

Answer : request.getParameter()

What does the `@WebFilter` annotation do?

1) Defines a filter class

2) Defines a servlet class

3) Manages HTTP sessions

4) Registers an EJB

Answer : Defines a filter class

Which of the following is NOT a method in the `HttpServlet` class?

1) doGet()

2) doPost()

3) service()

4) initSession()

Answer : initSession()

Which J2EE component is responsible for managing the lifecycle of session beans?

1) EJB Container

2) Servlet Container

3) Web Container

4) JMS Container

Answer : EJB Container

What is the role of `Session` management in J2EE?

1) Maintain state between client requests

2) Handle messaging

3) Manage database transactions

4) Process client requests

Answer : Maintain state between client requests

Which method is used to forward a request from one servlet to another?

1) request.getRequestDispatcher().forward()

2) response.forward()

3) session.forward()

4) request.redirect()

Answer : request.getRequestDispatcher().forward()