Professional Documents
Culture Documents
EJ Question Bank
EJ Question Bank
MCQs
A. 1
B. 2
C. 3
D. 4
a. ServltInputStream
b. ServletOutputStream
c. Both A & B
d. None of the above
a. RMI Communication
b. HTTP Communication
c. Socket Communication
d. All mentioned above
a. setAttribute
b. getAttribute
c. Both A & B
d. None of the above
10. Which cookie it is valid for single session only and it is removed
each time when the user closes the browser?
a. Persistent cookie
b. Non-persistent cookie
c. All the above
d. None of the above
11. Which method is used to send the same request and response
objects to another servlet in RequestDispacher ?
a. forward()
b. sendRedirect()
c. Both A & B
d. None of the above
a. javax.servlet
b. javax.servlet.http
c. Both A & B
d. None of the above
a. GenericServlet
b. HttpServlet
c. Both A & B
d. None of the above
a. GET
b. POST
c. BOTH A & B
d. None of the above
a. ServletConfig
b. ServletContext
c. Both A & B
d. None of the above
16. What is the lifecycle of a servlet?
a. HttpSession
b. URL rewriting
c. Cookies
d. Hidden form fields
18. Which one of the following scopes does the attribute in servlet
is an object that can be set, get or removed?
a. session scope
b. request scope
c. application scope
d. All mentioned above
a. 4
b. 3
c. 5
d. 2
20. Which of the following code can be used to set the content type for the body of the
response?
a. request.setContentType(type)
b. response.setContentType(type)
c. header.setContentType(type)
d. None of the above.
Short Question
1. Define Enterprise Application? with the help of a neat diagram illustrate the tiers of an Enterprise
Architecture.
2. List out the Technolgies used in Java EE.
3. With the help of the neat daiagram, illustrate the System Architectures that are used in
Computer Application
4. With the help of a neat diagram, illustrate each and every component used in Multi tier
Architecture
5. Why We use Servlets and What Servlets can do?
6. What are the intefaces used under javax.servlet interface? List out the methods used in all the
interfaces?
7. What are the intefaces used under javax.servlet.http interface? List out the methods used in all
the interfaces?
8. With the help of the neat diagram, illustrate the servlet lifecycle?
9. What is JDBC? what are the different types of JDBC Drivers
10. What are the Steps involved in to acess and work with a database using JDBC?
Module 2:
MCQs:
1. What is the better approach to set some application scoped value stetted from a
servlet
a. getServletContext().setAttribute("foo",barObj);
b. application.setAttribute("foo",barObj);
c. Both are good approach
d. None of these
4. Which of the following is the right placement for servlet class in a web archive file?
a. /WEB-INF/MyServlet.class
b. /WEB-INF/lib/MyServlet.class
c. /WEB-INF/class/MyServlet.class
d. /WEB-INF/classes/MyServlet.class
5. How should servlet developers handle the HttpServlet’s service() method when
extending HttpServlet?
a. They should override the service() method in most cases.
b. They should call the service() method from doGet() or doPost()
c. They should call the service() method from the init() method.
d. They should override at least one doXXX() method (such as doPost()).
8. <context-param>
<param-name>email</param-name>
<param-value>raj@123</param-value>
</context-param>
a. Can be assessed in any servlet/jsp
b. Can be assessed in any servlet but not in jsp
c. Can be assessed in an servlet in which it is defined
d. None of these
9. //assume imports
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws Exception{
PrintWriter out = response.getWriter();
out.println("hello"); out.flush();
request.getRequestDispatcher("/More").forward(request, response);}}
Assuming that Servlet in the path /More gets the PrintStream object and prints
“hello there”, what will happen when the Test servlet is requested?
a. Page displays hello
b. Page displays hello there
c. Page throws IllegalStateException
d. Page prints hello and hello there in 2 lines
11. If a client will NOT accept a cookie, which session management mechanism could
the web container employ? (Choose one.)
a. Cookies, but NOT URL rewriting.
b. URL rewriting, but NOT cookies.
c. Either cookies or URL rewriting can be used.
d. Neither cookies nor URL rewriting can be used.
12. The sendError() and sendRedirect() sends the status code equivalent to the static
constant
a. SC_NOT_FOUND and SC_MOVED_TEMPORARILY
b. SC_FOUND and SC_MOVED_TEMPORARILY
c. SC_MOVED_TEMPORARILY and SC_NOT_FOUND
d. SC_NOT_FOUND and SC_OK
14. What is the recommended way to deal with servlets and thread safety?
a. Write the servlet code to extend ThreadSafeServlet.
b. Have the servlet implement SingleThreadModel.
c. Use local variables exclusively, and if you have to use instance variables,
synchronize access to them.
d. Log all servlet method calls.
16. Which of the following is used to limit the number of rows returned?
a. setMaxRows(int i)
b. setMinRows(int i)
c. getMaxrows(int i)
d. getMinRows(int i)
19. Which of the following is an approach for state maintenance in Web applications?
a. URL Rewriting
b. Cookies
c. HTTP Session
d. All of the above.
20. Which method of the request object is used to extract values of the input fields in a
form when it is submitted?
a. getParameter
b. getParameterNames
c. getValues
d. putValues
1. Explain Cookies.
2. Explain advantages of cookies
3. What is servelt session?
4. Write syntax of creating a cookie
5. Write a syntax of deleting a cookie.
6. What is session tracking?
7. Why we use Hidden form filed ?
8. Why we use URL Rewriting?
9. What is request dispatcher interface?
10. Explain HTTP Session interface.
11. Explain constructor of cookie class.
12. What are the different kinds of cookies?
13. Name the methods of Request Dispatcher.
14. Explain getSession().
15. Explain getSession(boolean create).
Short Questions:
Long Questions:
1. What is Cookies? What are the prameters used in Cookies? Also List out the mandatory
parameter that a Cookie should use.
2. What are the Different Kinds of Cookies?
3. Where are Cookie used?
4. How cookies are Created using Servlet list out various method and syntax used to create
Cookies? also list out methods used in Cookies.
5. What are Sessions? Explain the Steps involved in the lifecycle of an HTTP Session?
6. Briefly Explain the Methods used in Session Tracking.
7. What is Request Dispatcher Interface? Write the Methods used for obtaining an Object
Implementation Request Dispatcher?
8. What are the Methods used in Request dispatcher?
9. What are the Methods used in Downloading the Files?
10. What are the interfaces need to be implemented while using the new non-blocking I/O
technology.
Module 3
MCQs:
1. Which of the following is/are true for JSP technology?
I. It is persistent.
II. Platform independent.
III. Browser executes the code.
a. Database service
b. Naming and Directory Service
c. Network Service
d. Web Service
a. Page
b. Session
c. Request
d. Application
4. Which method of the servlet is/are called several times in its life?
a. init()
b. doPost()
c. destroy()
d. Both (a) and (b) above
I. Request.
II. Session.
III. Vector.
IV. In.
6. Which of the following is not true for <jsp:useBean> tag in JSP page?
a. response.sendRedirect()
b. request.sendRedirect()
c. request.forward()
d. response.forward()
a. Simple property
b. Boolean property
c. Indexed property
d. Both (a) and (b) above
a. <jsp:include> Tag
b. <@ include> directive
c. <@ page > directive
d. Declaration block
a. ServeltContext
b. ServletConfig
c. RequestDispatcher
d. ResponseDispatcher
13. Which case of a session bean obtains the UserTransaction object via the
EJBContext using the getUserTransaction() method in EJB transaction
management?
a. Bean-managed transactions
b. Container-managed transactions
c. Both A & B
d. None of the above
15. Which session bean maintain their state between client invocations but are
not required to maintain their state across server crashes or shutdowns?
a. Stateful Session Bean
b. Stateless Session Bean
c. Singleton Session Bean
d. None of the above
16. Which EJB container must provide an implementation of Java Naming and
Directory Interface (JNDI) API to provide naming services for EJB clients
and components?
a. Transaction support
b. Persistence support
c. Naming support
d. All mentioned above
17. Which component does the Entity bean represent the persistent data
stored in the database?
a. Server-side component
b. Client-side component
c. server and client side component
d. None of the above
a. Entity Bean
b. Session Bean
c. Both A & B
d. None of the above
20. Which middleware services are provided by EJB?
a. Security
b. Transaction Management
c. Both A & B
d. None of the above
Short Questions:
1. What is Java Server Page Technology? Why do we use Java Server Pages ? Explain in
Details.
2. With the hep of a neat diagram illustrate the Lifecycle of a JSP page?
3. Write the Syntax used to
a. Format the Numbers
b. Parsing Numbers
c. Formatting the Date
d. Parsing the Date
e. Time Zones
Module 4:
MCQs:
19. Which server-side component is required to be deployed on the server?
a. EJB
b. RMI
c. Both A & B
d. None of the above
a. 2
b. 3
c. 4
d. 5
3. Which type of instances retain no data or conversational state for a specific client?
a. Message-Driven Bean
b. Session Bean
c. Entity Bean
d. None of the above
4. Which ways are used by the Log4j and Logback frameworks in hibernate framework to
support logging?
a. By log4j.xml file
b. By log4j.properties
c. Both A & B
d. None of the above
5. Which of the following is correct about Data Source in EJB persistence API?
a. It is a persistent object representing the data-store record. It is good to be
serializable.
b. it is an interface to do data operations like add/delete/update/find on
persistent object. It also helps to execute queries using Query interface.
c. It describes the properties of persistence mechanism.
d. It describes the data-store related properties like connection url. user-
name,password etc.
b. it is used to specify message listener interface for the message driven bean.
c. It is used to specify the configuration details of the message-driven bean in
operational environment of the message driven bean.
d. It is used to provide description of the message driven bean.
8. Which of the following is correct about @PostConstruct annotation for a callback method?
a. Method is invoked when a bean is created for the first time.
b. Method is invoked when a bean is removed from the bean pool or is destroyed.
c. Method is invoked when a bean is loaded to be used.
d. Method is invoked when a bean is put back to bean pool.
10. Which of the following is true about System level exception in EJB?
a. If business rule is voilated or exception occurs while executing the business logic will be
treated as system level exception.
b. Any exception which is not caused by business logic or business code.
RuntimeException, RemoteException are SystemException will be treated as system
level exception.
c. Both of the above.
d. None of the above.
11. Which statement describe about JMS is NOT true?
a. JMS supports Publish/Subcribe
b. JMS enhances access to email services
c. JMS use JNDI to locate the destination
d. None of the above
12. Which statement describe about Message-Driven Beans is correct?
a. Business Beans
b. Entity Beans
c. Session Beans
d. Message-Driven Beans
18. Which is NOT associated with the business tier in a JEE (J2EE) web-based application?
a. JSP
b. Entity Beans
c. Stateless Session Beans
d. None of the above
19. Which of the following elements defines the properties of an attribute that a tag needs?
a. Attribute
b. tag-attribute
c. tag-attribute-type
d. attribute-type
21. Which element defined within the taglib element of taglib descriptor file is
required?
a. Tag
b. Descriptor
c. Validator
d. Name
Very Short Questions:
Short Questions:
Module 5
MCQs:
17. What does the Session object hold?
e. First Level Cache
f. Second Level Cache
g. Both A & B
h. None of the above
a. Session
b. SessionFactory
c. Transaction
d. ConnectionProvider
3. In case of Table per Concrete class, there will be three tables in the database having no
relations to each other. Which are the ways to map the table?
e. By union-subclass element
f. By self-creating the table for each class
g. Both A & B
h. None of the above
6. Hibernate is an?
e. Open Source
f. Lightweight
g. ORM
h. All mentioned above
e. Data creation
f. Data manipulation
g. Data access
h. All mentioned above
a. Association validation
b. Association cascade behavior
c. Association multiplicity
d. Association direction
12. Object/relational metadata can be specified directly in the entity class file by using
annotations, or in a separate ________ descriptor file distributed with the application.
a. Scalable Vector Graphics
b. HTML
c. XML’
d. XHTML
15. What is TRUE about the cascading and cascade mode attributes in Entity Beans?
a. Cascade mode attributes can be specified for the association annotaions (like
@OneToMany) in an entity bean
b. The cascading direction is from the target entity to the source entity
c. PERSIST, DELETE and REFRESH are cascading mode attributes
d. Refresh cascade causes to refresh the target entities of a relationship when refresh is
invoked on the source entity of the relationship
16. Which of the following is true about detached state of a persistent entity?
a. Once we close the Hibernate Session, the persistent instance will become a detached
instance.
b. A new instance of a persistent class which is not associated with a Session.
c. You can make a transient instance detached by associating it with a Session.
d. None of the above.
17. Which element of hbm.xml defines maps the unique ID attribute in class to the primary
key of the database table?
a. Id
b. Generator
c. Primary key
d. None of the above
18. Which of the following element maps java.util.Map property in hibernate?
a. <set>
b. <list>
c. <bag>
d. <map>
Short Questions:
1. What is persistence in JPA?Explain
2. Explain the architecture of JPA
3. How JPA works?
4. What is Hibernate? Why Hibernate?
5. How Hibernate Works?
6. How to run The JPA Application?
7. How to run the Hibernate Application?
8. Explain the architecture of Hibernate with the help of diagram.
9. Explain the JPA Application Structure.
10. How to create Persistence Unit?
Long Questions: