Learn J2EE MCQs
Prepare J2EE MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a valid annotation for a JAX-RS resource method?
1) @GET
2) @SET
3) @POST
4) @UPDATE
Answer : @GET
What is the main purpose of `EJB`?
1) Business logic
2) Presentation layer
3) Database access
4) Messaging
Answer : Business logic
Which method is used to remove a session attribute in a servlet?
1) removeAttribute()
2) setAttribute()
3) getAttribute()
4) invalidate()
Answer : removeAttribute()
Which of the following annotations is used to define a RESTful service in J2EE?
1) @Path
2) @Service
3) @Controller
4) @WebService
Answer : @Path
What is the primary purpose of `ServletRequest`?
1) To encapsulate request data
2) To manage session state
3) To handle responses
4) To provide a configuration context
Answer : To encapsulate request data
Which of the following is a valid annotation for declaring a transaction in EJB?
1) @Transactional
2) @Transaction
3) @TransactionAttribute
4) @TransactionManagement
Answer : @TransactionAttribute
Which lifecycle method is called to destroy a servlet?
1) destroy()
2) init()
3) service()
4) doGet()
Answer : destroy()
Which of the following is NOT a type of EJB?
1) Session Bean
2) Message-Driven Bean
3) Entity Bean
4) Control Bean
Answer : Control Bean
What is the role of `ServletContextListener`?
1) To respond to changes in the servlet context
2) To handle HTTP requests
3) To manage session data
4) To define servlets
Answer : To respond to changes in the servlet context
Which method is called to commit a transaction in JTA?
1) commit()
2) rollback()
3) begin()
4) end()
Answer : commit()