Learn J2EE MCQs

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

What is the main function of `Entity Bean` in J2EE?

1) Represent persistent data

2) Handle messaging

3) Manage sessions

4) Process requests

Answer : Represent persistent data

Which J2EE component is used for handling HTTP requests?

1) Servlet

2) EJB

3) JMS

4) JNDI

Answer : Servlet

Which protocol does `JMS` use for asynchronous communication?

1) TCP

2) HTTP

3) JNDI

4) None, it is protocol-agnostic

Answer : None, it is protocol-agnostic

Which method in a servlet responds to a client request?

1) service()

2) doGet()

3) init()

4) destroy()

Answer : service()

What is the purpose of the `doGet()` method in a servlet?

1) Handle GET requests

2) Handle POST requests

3) Process client authentication

4) Terminate a session

Answer : Handle GET requests

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

1) Configures a servlet in the deployment descriptor

2) Registers a servlet with a URL pattern

3) Defines a JSP page

4) Manages HTTP sessions

Answer : Registers a servlet with a URL pattern

Which of the following is used to maintain state in a web application?

1) Session

2) Request

3) Servlet

4) JSP

Answer : Session

What does the `destroy()` method do in the servlet lifecycle?

1) Terminates the servlet

2) Processes the request

3) Initializes the servlet

4) Handles client requests

Answer : Terminates the servlet

Which of the following methods is used to handle a GET request in a servlet?

1) doGet()

2) doPost()

3) service()

4) init()

Answer : doGet()

What is the purpose of `JMS` in J2EE?

1) Database connection

2) Asynchronous messaging

3) Servlet management

4) Transaction management

Answer : Asynchronous messaging