Learn J2EE MCQs

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

What is the purpose of the `JTA` in J2EE?

1) Handle asynchronous messaging

2) Transaction management

3) Session tracking

4) Directory lookup

Answer : Transaction management

Which design pattern in J2EE is used to handle concurrent access to shared resources?

1) Singleton

2) Adapter

3) Observer

4) Proxy

Answer : Singleton

What is the main function of `JSP` in J2EE?

1) To handle HTTP requests

2) To generate dynamic content

3) To manage database connections

4) To implement business logic

Answer : To generate dynamic content

Which of the following is used for transaction management in J2EE?

1) JDBC

2) JNDI

3) JTA

4) JMS

Answer : JTA

Which tag is used in web.xml to define security roles?

1) <security-role>

2) <role-name>

3) <security-constraint>

4) <login-config>

Answer : <security-role>

What is the primary use of `Session` in J2EE?

1) Store client-specific data

2) Handle requests

3) Render dynamic content

4) Manage transactions

Answer : Store client-specific data

Which of the following J2EE components is responsible for managing the lifecycle of a servlet?

1) Servlet Container

2) EJB Container

3) JMS Container

4) JDBC Driver

Answer : Servlet Container

Which of these is a valid lifecycle method in a servlet?

1) init()

2) create()

3) execute()

4) start()

Answer : init()

Which J2EE technology is used to render Java code within HTML pages?

1) JSP

2) Servlet

3) JDBC

4) EJB

Answer : JSP

Which method is called once during the servlet lifecycle?

1) init()

2) destroy()

3) service()

4) doGet()

Answer : init()