Learn J2EE MCQs
Prepare J2EE MCQs (Multiple choice Questions) for exam and job interviews.
Which method in a servlet is used to handle a request from the client?
1) doPost()
2) doGet()
3) service()
4) init()
Answer : service()
What does the `<filter>` tag define in web.xml?
1) A servlet
2) A security constraint
3) A filter
4) An error page
Answer : A filter
What does the `destroy()` method do in a servlet?
1) Initializes the servlet
2) Processes requests
3) Closes resources and terminates the servlet
4) Manages sessions
Answer : Closes resources and terminates the servlet
Which J2EE component is used to manage asynchronous messaging?
1) JMS
2) JDBC
3) EJB
4) JNDI
Answer : JMS
Which protocol is used for remote method invocation in J2EE?
1) RMI
2) HTTP
3) FTP
4) SMTP
Answer : RMI
What is the main role of `Session Bean` in J2EE?
1) Manage database access
2) Handle messaging
3) Implement business logic
4) Manage session data
Answer : Implement business logic
What is the role of `JSP` in J2EE?
1) Handle server-side logic
2) Render dynamic content
3) Manage client requests
4) Manage sessions
Answer : Render dynamic content
What does the `@WebFilter` annotation in J2EE define?
1) A filter class
2) A servlet class
3) A web service
4) A session
Answer : A filter class
Which of the following is true about `EJB` in J2EE?
1) It is used for transaction management
2) It is used to manage HTTP requests
3) It handles database connections
4) It provides UI rendering
Answer : It is used for transaction management
What is the purpose of `Servlet` in J2EE?
1) To manage database connections
2) To handle web requests and responses
3) To handle messaging
4) To manage HTTP sessions
Answer : To handle web requests and responses