Learn J2EE MCQs

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

What is the role of the `@RequestParam` annotation?

1) To bind request parameters to method parameters

2) To define a REST endpoint

3) To manage transactions

4) To inject dependencies

Answer : To bind request parameters to method parameters

Which of the following is used to create a new instance of an EJB?

1) new MyBean()

2) @EJB MyBean myBean

3) create MyBean()

4) getMyBean()

Answer : @EJB MyBean myBean

Which of the following annotations is used to mark a class as a controller in Spring MVC?

1) @Controller

2) @RestController

3) @Service

4) @Component

Answer : @Controller

What does the `@GetMapping` annotation do in Spring?

1) Maps HTTP GET requests to specific handler methods

2) Maps HTTP POST requests

3) Defines a REST service

4) Handles transactions

Answer : Maps HTTP GET requests to specific handler methods

Which technology is used for creating dynamic web pages in Java?

1) JSP

2) JDBC

3) Servlet

4) JSF

Answer : JSP

What does EJB stand for?

1) Enterprise JavaBeans

2) Enterprise JavaBase

3) Enhanced JavaBeans

4) Enterprise JavaBlocks

Answer : Enterprise JavaBeans

Which of the following is a valid way to define a servlet in web.xml?

1) <servlet>

2) <servlet-mapping>

3) <filter>

4) <listener>

Answer : <servlet>

What is the primary use of JPA?

1) Object-relational mapping

2) Creating web services

3) Handling HTTP requests

4) Managing transactions

Answer : Object-relational mapping

Which Java API is used for sending messages between applications?

1) JMS

2) JDBC

3) JNDI

4) JPA

Answer : JMS

Which annotation is used to define a RESTful resource in Spring?

1) @RestController

2) @Controller

3) @Service

4) @Component

Answer : @RestController