Learn J2EE MCQs

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

Which tag is used to configure security constraints in J2EE?

1) <security-constraint>

2) <filter>

3) <servlet>

4) <session>

Answer : <security-constraint>

What does the `@WebServlet` annotation in J2EE define?

1) Servlet class

2) Session Bean

3) JSP file

4) Web Filter

Answer : Servlet class

Which method is used to handle HTTP POST requests in servlets?

1) doGet()

2) doPost()

3) service()

4) init()

Answer : doPost()

What does the `service()` method in a servlet do?

1) Handles all HTTP requests

2) Initializes the servlet

3) Handles POST requests

4) Destroys the servlet

Answer : Handles all HTTP requests

What is the role of the `EJB Container` in J2EE?

1) Manages EJB lifecycle

2) Handles client requests

3) Processes HTTP requests

4) Manages JSP lifecycle

Answer : Manages EJB lifecycle

Which technology in J2EE is used for handling transactions?

1) JTA

2) JSP

3) EJB

4) JDBC

Answer : JTA

What is the main purpose of `JNDI` in J2EE?

1) Directory and Naming services

2) Asynchronous messaging

3) Database transactions

4) User authentication

Answer : Directory and Naming services

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

1) doGet()

2) doPost()

3) service()

4) execute()

Answer : execute()

What is the purpose of the `<listener>` tag in web.xml?

1) To configure listeners

2) To define a filter

3) To handle transactions

4) To define servlets

Answer : To configure listeners

What is `WAR` in J2EE?

1) Web Application Resource

2) Web Application Registry

3) Web Application Archive

4) Web Application Reference

Answer : Web Application Archive