Learn J2EE MCQs

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

What is the purpose of the `@WebListener` annotation?

1) Defines a web listener class

2) Defines a servlet

3) Defines a session bean

4) Defines a web filter

Answer : Defines a web listener class

What does `JTA` stand for in J2EE?

1) Java Transaction API

2) Java Type API

3) Java Transfer API

4) Java Table API

Answer : Java Transaction API

Which of the following is NOT a valid session tracking method in J2EE?

1) Cookies

2) URL rewriting

3) Session ID

4) JavaBean

Answer : JavaBean

Which protocol is used by a servlet to handle requests?

1) FTP

2) HTTP

3) SMTP

4) SOAP

Answer : HTTP

What is the correct annotation to declare a stateless session bean in J2EE?

1) @Stateless

2) @Stateful

3) @SessionBean

4) @ManagedBean

Answer : @Stateless

Which method is used to get a request parameter in a servlet?

1) request.getParameter()

2) request.getAttribute()

3) response.getParameter()

4) response.getAttribute()

Answer : request.getParameter()

Which is the correct method to include content from another servlet or JSP?

1) RequestDispatcher.include()

2) RequestDispatcher.forward()

3) HttpSession.include()

4) ServletContext.include()

Answer : RequestDispatcher.include()

Which tag is used to define the root element in web.xml?

1) <web-app>

2) <servlet>

3) <context>

4) <filter>

Answer : <web-app>

Which HTTP method should be idempotent?

1) GET

2) POST

3) PUT

4) DELETE

Answer : GET

Which of the following is NOT a valid J2EE application component?

1) EJB

2) JSP

3) Servlet

4) Applet

Answer : Applet