Learn J2EE MCQs
Prepare J2EE MCQs (Multiple choice Questions) for exam and job interviews.
Which method is called when a servlet is initialized?
1) init()
2) doPost()
3) service()
4) destroy()
Answer : init()
Which of the following is true about a stateless session bean?
1) It does not maintain state between method calls
2) It maintains state between requests
3) It is used for session tracking
4) It is responsible for client authentication
Answer : It does not maintain state between method calls
What does the `destroy()` method in a servlet do?
1) Releases resources and terminates the servlet
2) Initializes the servlet
3) Handles HTTP requests
4) Processes form data
Answer : Releases resources and terminates the servlet
Which of the following technologies is used for messaging in J2EE?
1) JMS
2) EJB
3) JSP
4) Servlet
Answer : JMS
What is the purpose of `Entity Beans` in J2EE?
1) Represent persistent data in a database
2) Handle HTTP requests
3) Manage client sessions
4) Render dynamic web content
Answer : Represent persistent data in a database
What does `JTA` stand for in J2EE?
1) Java Transaction API
2) Java Transaction Application
3) Java Transaction Architecture
4) Java Transport API
Answer : Java Transaction API
What is the purpose of the `doGet()` method in a servlet?
1) Handles HTTP GET requests
2) Processes form data
3) Manages sessions
4) Handles HTTP POST requests
Answer : Handles HTTP GET requests
Which of the following is a design pattern used in J2EE?
1) Model-View-Controller
2) Factory
3) Adapter
4) Builder
Answer : Model-View-Controller
Which method is used to set attributes in an HTTP session?
1) setAttribute()
2) addAttribute()
3) putAttribute()
4) saveAttribute()
Answer : setAttribute()
Which J2EE component is responsible for handling client requests?
1) Servlet
2) EJB
3) JMS
4) JSP
Answer : Servlet