Learn J2EE MCQs

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

Which of the following annotations is used to define a filter in J2EE?

1) @Servlet

2) @Filter

3) @WebFilter

4) @Listener

Answer : @WebFilter

What is the role of a `Stateful Session Bean` in J2EE?

1) Handles messaging

2) Manages web requests

3) Maintains client state between method calls

4) Manages database connections

Answer : Maintains client state between method calls

Which is a method in `HttpServletRequest`?

1) getParameter()

2) sendError()

3) getWriter()

4) setSession()

Answer : getParameter()

What does `ServletConfig` contain?

1) Information about the servlet container

2) Servlet initialization parameters

3) Session information

4) User credentials

Answer : Servlet initialization parameters

Which of the following is used for messaging in J2EE?

1) JMS

2) JDBC

3) JSP

4) Servlet

Answer : JMS

What is the purpose of `JAX-RS` in J2EE?

1) Handle web services

2) Connect to databases

3) Manage transactions

4) Render dynamic content

Answer : Handle web services

What is the scope of a `ServletContext`?

1) Request

2) Application

3) Session

4) Thread

Answer : Application

What does `@SessionScoped` annotation define?

1) A servlet

2) A session-scoped bean

3) A stateless bean

4) A JSP

Answer : A session-scoped bean

What is the default session timeout in J2EE (in minutes)?

1) 30

2) 60

3) 20

4) 15

Answer : 30

What is the function of a `Stateless Session Bean`?

1) Maintains client state

2) Does not maintain client state

3) Handles messaging

4) Manages transactions

Answer : Does not maintain client state