Learn J2EE MCQs

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

Which tag in `web.xml` is used to configure a servlet?

1) <servlet>

2) <filter>

3) <listener>

4) <security>

Answer : <servlet>

What is the purpose of the `@Stateless` annotation in J2EE?

1) Defines a stateless session bean

2) Defines a stateful session bean

3) Defines a listener

4) Defines a servlet

Answer : Defines a stateless session bean

Which method in J2EE is used to retrieve HTTP request parameters?

1) request.getParameter()

2) request.getAttribute()

3) session.getParameter()

4) response.getParameter()

Answer : request.getParameter()

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

1) Defines a filter for requests

2) Defines a servlet

3) Defines a listener

4) Handles session management

Answer : Defines a filter for requests

Which of the following is NOT a component of J2EE?

1) Servlets

2) JSP

3) JMS

4) PHP

Answer : PHP

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

1) It does not maintain state between method calls

2) It maintains state between method calls

3) It handles transactions

4) It is used for session tracking

Answer : It does not maintain state between method calls

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

1) doGet()

2) run()

3) execute()

4) load()

Answer : doGet()

What is the role of the `web container` in J2EE?

1) Manages the lifecycle of servlets and JSPs

2) Manages EJBs

3) Manages the database

4) Handles HTTP sessions

Answer : Manages the lifecycle of servlets and JSPs

Which of the following is a component of the `J2EE architecture`?

1) JSP

2) SQL

3) PHP

4) Python

Answer : JSP

What is the purpose of the `@SessionScoped` annotation in J2EE?

1) Manages session-scoped beans

2) Defines a stateless session bean

3) Defines a filter

4) Handles HTTP requests

Answer : Manages session-scoped beans