Learn J2EE MCQs
Prepare J2EE MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a characteristic of EJB?
1) Distributed transactions
2) Simplicity
3) Lightweight
4) Stateless
Answer : Distributed transactions
What is the primary purpose of the `@RequestMapping` annotation?
1) To map requests to specific handler methods
2) To define a RESTful web service
3) To handle HTTP requests
4) To inject dependencies
Answer : To map requests to specific handler methods
Which annotation is used to define a RESTful web service in JAX-RS?
1) @Path
2) @Service
3) @Controller
4) @Rest
Answer : @Path
What is the default scope of a Spring bean?
1) Singleton
2) Prototype
3) Request
4) Session
Answer : Singleton
What does the `@Transactional` annotation do?
1) Manages transaction boundaries
2) Defines a web service
3) Handles HTTP requests
4) Defines a component
Answer : Manages transaction boundaries
What type of bean is created by default in Spring?
1) Singleton
2) Prototype
3) Request
4) Session
Answer : Singleton
Which interface is used for event handling in Spring?
1) ApplicationListener
2) EventListener
3) MessageListener
4) ServletContextListener
Answer : ApplicationListener
What is the purpose of the `@Service` annotation in Spring?
1) Defines a service layer component
2) Defines a controller
3) Defines a repository
4) Defines a REST endpoint
Answer : Defines a service layer component
Which of the following is used to configure a web application in J2EE?
1) web.xml
2) application.properties
3) persistence.xml
4) config.xml
Answer : web.xml
Which method is used to read an input stream in servlets?
1) request.getInputStream()
2) request.readStream()
3) request.getStream()
4) request.getInput()
Answer : request.getInputStream()