Learn J2EE MCQs

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

Which of the following is a core J2EE design pattern?

1) Factory

2) Singleton

3) DAO

4) Adapter

Answer : DAO

Which annotation is used to define a servlet in J2EE?

1) @Servlet

2) @WebService

3) @WebServlet

4) @WebFilter

Answer : @WebServlet

What is the purpose of `JSP` in J2EE?

1) Manage HTTP sessions

2) Generate dynamic web pages

3) Connect to databases

4) Manage business logic

Answer : Generate dynamic web pages

Which of the following is used for distributed communication in J2EE?

1) JDBC

2) JMS

3) RMI

4) JNDI

Answer : RMI

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

1) Processes HTTP requests

2) Initializes the servlet

3) Shuts down the servlet

4) Manages sessions

Answer : Processes HTTP requests

Which method is used to handle `GET` requests in a servlet?

1) doPost()

2) doGet()

3) service()

4) init()

Answer : doGet()

Which J2EE component is used to render Java code inside HTML pages?

1) JSP

2) EJB

3) JMS

4) Servlet

Answer : JSP

What is the function of `EJB` in J2EE?

1) Manage database connections

2) Implement business logic

3) Handle web requests

4) Generate dynamic content

Answer : Implement business logic

What is `JTA` primarily used for?

1) Transaction management

2) Directory services

3) Messaging

4) Session management

Answer : Transaction management

Which J2EE pattern is used to decouple business logic from presentation?

1) DAO

2) Singleton

3) MVC

4) Factory

Answer : MVC