Java Technologies - 2 PG DAC
Java Technologies - 2 PG DAC
Java Technologies - 2 PG DAC
Contents
HIBERNATE ...................................................................................................................................................................... 1
JDBC................................................................................................................................................................................. 5
JSF.................................................................................................................................................................................... 8
JSP ................................................................................................................................................................................... 8
MVC ............................................................................................................................................................................... 14
SERVLET ......................................................................................................................................................................... 15
STRUTS .......................................................................................................................................................................... 23
SPRING .......................................................................................................................................................................... 26
SWING ........................................................................................................................................................................... 28
HIBERNATE
1. Hibernate entity can be
A: transient
B: detached
C: persistent
D: all of the above
2. When transaction completes, all the associated persistent objects still exists in memory but they lose
their association with the session on encountering one of the following method
A: session.flush()
B: trasaction.close()
C: session.close()
D: none of the above
3. In hibernate,If the developer is not certain about the existence of the object.
A: load() method should be used
B: get() method should be used
C: retrieve() method should be used
D: all the above are same with not much difference.
8. A join which combines result of both left and right outer join is
A: Left Right Join
B: Right Outer Join
C: Full Join
D: Left Join
13. Once the hibernate session is closed, in which state the object remains?
A: detached
B: transient
C: pesistent
D: garbage collector
2
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
15. What does <generator-class=”native”/> means?
a. Generate primary key
b. Generate tables based on configuration
c. Generate sql statements on configuration
d. None
18. When we integrate Hibernate via spring we don‘t need to take care of.
A: SessionFactory
B: Session
C: Both a and b. (since there is something called as “HibernateTemplate” in spring)
D: None of the above.
3
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
23. Is Hibernate Session threadsafe?
a) Yes b) no c) no relation with thread d) none
34. There are core interfaces that are used in just about every hibernate application. Using these
interfaces, you can store and retrieve persistent object and control transactions. Select all the interfaces
that you see.
a. Configuration interface
b. Query and Criteria interfaces
c. All of the above
d. None of the above
36. If the validation fails what will be returned by the validate () method?
a) Success b) input c) login d) error
JDBC
1. Which of the following code will you use to get a count of the columns in the result?
A. ResultMetaData rsmd=DatabaseMetaData.getMetaData();
int columns=rsmd.getColumnCount();
B. ResultSetMetaData rsmd=new ResultSetMetaData(result);
int columns=rsmd.getColumnCount();
C. ResultSetMetaData rsmd=result.getMetaData();
int columns=rsmd.getColumnCount();
D. DatabaseMetaData md=result.getMetaData();
int columns=md.getColumnCount();
5
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
5. Which of the following statements is NOT true about a PreparedStatement
a. PreparedStatement is pre-compiled
b. PreparedStatement may have both IN and OUT parameters.
c. Execution of PreparedStatement is faster than Statement.
d. All of the above
10. If we use query statement inside “execute()” method of Statement, it will return
A: false B: true C: 1 D: 0
11. If we use update statement inside “execute()” method of Statement, it will return
A: false B: true C: 1 D: 0
13. Connection is
A: interface B: class C: package D: None of the above.
14. Name the most suitable execution method in JDBC , for firing DML queries.
a. executeQuery()
b. executeUpdate()
c. executeQueue()
d. executeDynamicQuery()
17. Which driver is efficient and always preferable for jdbc applications?
a) Type – 4 b) Type –1 c) Type –3 d) Type –2
18. The parameters of PreparedStatement object are _______ when the user clicks on the query button.
a) Initialized b) started c) paused d) stopped
27. Every driver class has ________ which registers itself with the DriverManager
a) Static method
b) static block
c) constructor
d) none of the above
JSF
1. Front Controller in JSF is
a) DispatcherServlet
b) ActionServlet
c) FacesServlet
d) none of the above
JSP
1. Which of the attribute of JSP mentioned below is not available in servlet?
A: request
B: session
C: page
D: context
7. Given
<jsp:useBean id=”a1” scope=”request” class=”mypack.Customer”/>
What is the syntax to read Customer object?
A: ${requestScope.a1}
B: <%=request.getAttribute(“a1”)%>
C: ${a1}
D: all the above
8. Which JSP expression tag will print the context initialization parameter named “uname”?
A: <%= application.getAttribute(“uname”)%>
B: <%= application.getInitParameter(“uname”)%>
C: <%= request.getParameter(“uname”)%>
D: <%=contextParam.get(“uname”)%>
10. The implicit JSP objects like request, response, and out are only visible in the _jspService() method.
a. True b. False
11. To fill up all bean properties with HTML form elements which of the following statements can be used,
a. <jsp:synchronize name="BeanName" />
b. <jsp:setProperty name="BeanName" property="" />
c. <jsp:setProperty name="BeanName" property="*" />
d. <jsp:setProperty name="BeanName" property="All" />
12. Why use RequestDispatcher to forward a request to another resource, instead of using a sendRedirect?
a. Redirects are no longer supported in the current servlet API.
b. Redirects are not a cross-platform portable mechanism
c. The RequestDispatcher does not use the reflection API.
9
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
d. The RequestDispatcher does not require a round trip to the client, and thus is more efficient and
allows the server to maintain request state.
13. The attribute which defines your jsp page as a exception handling page is
a. isExceptionPage
b. exceptionPage
c. isErrorPage
d. w. errorPage
18. What is the effect of executing the following JSP statement, assuming a class with name Employee
exists in class’s package?
<%@ page import = "classes.Employee" %>
<jsp:useBean id="employee" class="classes.Employee" scope="session"/>
<jsp:setPropertv name="employee" property="*"/>
A: The code does not compile as there is no properly attribute of setProperty tag.
B: The code does not compile as property attribute cannot take * as a value.
C: The code sets value of all properties of employee bean to "*".
D: The code sets the values of all properties of employee bean to matching parameters in request object.
19. If a JSP page overrides the jsplnit() method using a declaration JSP tag, which phase of the JSP page
life-cycle generates the overridden method in the servlet?
A: page translation. B: JSP page compilation.
C: call jsplnit() D: call_jspService().
10
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
21. Which method can be overridden while writing JSP page
a. jspInit
b. JspDestroy
c. A and B both
d. None of the above
24. The attribute which informs container about a particular error jsp page is
A. isExceptionPage
B. exceptionPage
C. isErrorPage
D. errorPage
26. if a jsp page overrides the jspInit method using a declaration JSP tag , which phase of the jsp page life-
cycle generates the overridden method in servlet?
a) Page translation b) JSP page compilation c) call jspInit() d) call _jspService()
27. Select the correct statement about following code (Select one)
<%@page language="java"%>
<html><body>
<%
response.getOutputStream().print("hello");
out.print("World");
%>
</body></html>
a. It will print “hello World” in the output
b. It will generate compile time errors
c. It will throw runtime exceptions (java.lang.IllegalStateException: getOutputStream() has already
been called for this response)
d. It will only print “hello”
11
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
29. Which among the following will compile?
a) <% int x=10 %>
b) <%= “hello how are you” %>
c) <%= “hello” ; %>
d) <%! Int x=10 %>
30. Which of the following statements is true regarding the scope of “request” in JSP?
a. Objects with request scope are accessible from pages processing the same request where they
were created.
b. All references to the object shall be released after the request is processed: in particular if the
request is forwarded to a resource in the same runtime , the object is still reachable.
c. References to the objects in request scope are stored in a request object.
d. All of the above.
31. Which of the following statements makes your compiled JSP page implement the SingleThreadModel
interface?
a. <%@ page isThreadSafe="false" %>
b. <%@ page isThreadSafe="true" %>
33. When using a JavaBean to get all the parameters from a form, what must the property be set to (???
in the following code) for automatic initialization?
<jsp:useBean id="fBean" class="govi.FormBean" scope="request"/>
<jsp:setProperty name="fBean" property="???" />
<jsp:forward page="/servlet/JSP2Servlet" />
a. * b. All c. @ d. =
34. Choose the statement that best describes the relationship between JSP and servlets:
a. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.
b. JSP and servlets are unrelated technologies.
c. Servlets and JSP are competing technologies for handling web requests. Servlets are being
superseded by JSP, which is preferred. The two technologies are not useful in combination.
d. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
35. What alternatives exist to embedding Java code directly within the HTML markup of your JSP page?
a. Moving the code into your session manager.
b. Moving the code into scriptlets.
c. Moving the code into JavaBeans and servlets
d. Moving the code into a transaction manager
36. What is the initial contact point for handling a web request in a Page-Centric architecture?
12
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
a. A JSP page
b. A JavaBean.
c. A servlet.
d. A session manager
37. Which object would you use to share user specific information between JSPs?
a. Request b. Response c. Session d. Application
38. Which of the following rules must a reusable JavaBeansTM component adhere to?
a. The Bean class must provide zero argument constructors.
b. The Bean must have a corresponding BeanInfo class.
c. The Bean must only use visible components.
d. The Bean must not be serializable.
39. Which of the following is not a standard method called as part of the JSP life cycle?
a. jspInit()
b. jspService()
c. _jspService()
d. jspDestroy()
40. If you want to override a JSP file's initialization method, within what type of tags must you declare the
method?
a. <@ @>
b. <%@ %>
c. <% %>
d. <%! %>
41. Which of the following cannot be used as the scope when using a JavaBean with JSP?
a. Application
b. Session
c. Request
d. Response
e. Page
42. What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()?
a. forward executes on the client while sendRedirect() executes on the server
b. Forward executes on the server while sendRedirect() executes on the client.
c. The two methods perform identically.
46. One of the following is an additional attribute in Jsp as compare to servlet attributes .
13
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
a) Request b) context c) page d) response e) session
47. Two of the following are used to call bean class setter and getter methods.
A) setAttribute b) getProperty c) getAttribute d) setProperty
49. When jsp is generated into servlet it is derived from which class
a) HttpServlet b) HttpJspBase c) HttpJspPage d) Servlet
51. For every tag encounter, a new instance of Tag Class is created.
a. True b. False
52. One of the following JSTL tag performs URL rewriting Select one:
A.url
B.aHref
C.import
D.link
MVC
1. One of the following is responsible for responding to user input and perform interactions on the data
model objects.
14
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
A: model B: view C: controller D: none of them
SERVLET
1. Select the correct statement
A: ServletConfig is not available inside constructor
B: servlet gets instantiated every time a new request comes.
C: programmer has to override “service()” method of parent class
D: GenericServlet is a concrete class
3. In order to retrieve existing session only [not to create new] which function should be used ?
A: getSession(true) B: getSession()
C: getSession(false) D: all of the above
15
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
9. execute() for any DML or DDL return Boolean
12. Which of the following method is not used to retrieve request parameters?
A: getParameterNames()
B: getParameter()
C: getParameterVaIue()
D: None of the Above
14. Depending upon the events on servlet we can specify the following levels_____________.
A: Request level events
B: ServletContext level events
C: Only A
D: Both A and B
16. You want to use URL rewriting to support client browsers, which do not use cookies. Which method
will you use to attach the session id to a URL that is to be used for the sendRedirect() method of the
HttpServletResponse?
A: encodeURL
B: encodeRedirectURL
16
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
C: encodeSessionURL
D: encodeSessionRedirectURL
17. Given that the service() method of a typical servlet is multithreaded, which one of the following issues
does NOT need to be addressed in a servlet's implementation?
a. Concurrent access to shared resources
b. Concurrent access to local variables
c. Concurrent access to static variables
d. Concurrent access to instance variables
18. _______ is the object used for reading “init” or “config” parameters.
A) ServletContext b) ServletConfig c) RequestDispatcher
21. Following methods are the part of servlet lifecycle. [Choose 3 correct answers]
A) Start b) init c) stop d) service e) destroy
28. Following interface is used to either forward or include other web resource. A)
Servlet b) RequestDispatcher c) ServletConfig d) HttpResponse
17
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
29. Besides the cookie object which other object is also required to create a cookie on the browser?
a. Request
b. Response
c. Session
d. Application
32. Your web application named bank uses “WelcomeServlet”. Where will u store
“WelcomeServlet.class”?
a. bank/WEB-INF/classes
b. bank/WEB-INF/lib/classes
c. root/WEB-INF/lib
d. bank/WebContent/lib/classes
33. What method can be used to retrieve value of the request parameter being sent as a part of the
request by client?
a. Use the method “HttpServletRequest.getParameter(string name) which will return String form.
b. Use the method “HttpServletRequest.getParameterValues() which will return array of String
values.
c. Use the method “HttpServletResponse.getValues()” which will return array of string values.
d. There is no direct support in servlet api.
35. If the HTTP error 500 is generated by your servlet, you do not want to show the “Internal Server Error”
page to the client. Instead, you want a custom error page to be displayed. What is the best way to
accomplish this?
a. Forward the user to the error page using HttpServletResponse.sendRedirect() method.
b. Forward the user to the error page using RequestDispatcher.forward() method.
c. Specify the mapping of the error-code 500 and the error-page in the deployment descriptor.
d. It is not possible to accomplish this.
18
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
36. Which of the following should not be used to share data between servlets in a distributed web
application?
a. Attributes of ServletContext
b. Enterprise JavaBeans
c. Attributes of HttpSession
d. Database
37. You want to use URL Rewriting to support client browsers which do not use cookies. Which method
will you use to attach the session id to a url that is to be used for the “sendRedirect()” method of the
HttpServletResponse?
a) encodeURL b) encodeRedirectURL c) encodeSessionURL d) encodeSessionRedirectURL
39. A user types the URL http://www.cdac.in which Http request gets generated?
a. GET method
b. POST method
c. HEAD method
d. PUT method
40. Which object is used to forward the request processing from one servlet to another?
a. ServletContext
b. ServletConfig
c. RequestDispatcher
d. ResponseDispatcher
41. The method getWriter() returns an object of type PrintWriter. This class has println() method to
generate output. Which of these classes define the getWriter method? Select the one correct answer.
a. HttpServletRequest
b. HttpServletResponse
c. ServletContext
d. ServletConfig
43. Which of the following method is not used to reterive request parameters
A: getParameterNames()
19
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
B: getParameter()
C: getParameterVaIue()
D: None of the Above
48. In order to make Servlet entry inside DD, we need to mention _______.
A. Servlet-Class
B. Servlet-name
C. URL-pattern
D. All of these
56. Request Dispatcher reference can be used for forward as well as include
A. False B. True
70. If u want to ensure servlet loading even before first request u need to use
A. <start-on-load>
B. <load-on-startup>
C. <load-on-start>
D. none of these
75. What is the difference between doing an include or a forward with a RequestDispatcher?
A. The forward method transfers control to the designated resource, while the include method invokes the
designated resource, substitutes its output dynamically in the display, and returns control to the calling
page.
B. The two methods provide the same functionality, but with different levels of persistence
C. The forward method is deprecated as of JSP 1.1 and the include method should be used in order to
substitute portions of a dynamic display at runtime.
D. The include method transfers control to a dynamic resource, while the forward method allows for
dynamic substitution of another JPS pages output, returning control to the calling resource.
STRUTS
1. Following is the main controller in struts2 framework
A: StutsPrepreAndExcuteFilter
B: ActionServlet
C: FilterServlet
D: FilterController
4. In action tag, when method is not specified, which method is by default considered?
A: run
B: actionexecute
C: execute
D: perform
5. One of the following is the map in OGNL to retrieve any type of attribute
A: request
B: application
C: page
D: attr
6. Which is the interface used if you want to access “request” object in your action class?
A: ServletRequest
B: HttpServletRequest
C: ServletRequestAware
23
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
D: RequestAware
10. EL maps
pageScope Scoped variables from page scope
13. Interceptor does __________&________processing of request and invokes the action classes.
A: pre, post B: before, after C: get, post D: None of the above
24
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
14.Which interceptor is used for internationalization in struts?
A: struts.custom.i17n.resources
B: struts.custom.i18n
C: struts.custom.i18n.resources
D: struts.i18n.custom.resources
19. _____________ is the interceptor stack available by default to every sturts application.
A) execAndWait b) validateStack c) defaultStack
20. By default result name is _____________
a) success b) fail c) retry d) abort
21. In action tag, when method is not specified ___________ is the by default method considered.
A) run b) execute c) actionExecute d) perform
22. We can forward the request from one action class to another. True
29. __________ is the interface used if you want to access “request” object in your action class.
A) ServletRequest b) HttpServletRequest c) ServletRequestAware d) RequestAware
30. If the action name is “AddAction”, the validation file name should be ______________
a) AddAction-validation.xml
b) AddAction-validator.xml
c) AddAction_validation.xml
SPRING
1. Spring controller can be defined using annotation
a) @Bean
b) @Component
c) @Controller
d) none of the above
3. The advice functionality takes place after the advised method completes, regardless of the outcome:
a) after-returning
b) After
c) after-throwing
d) None of the above
26
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
7. Join points can be method calls, constructor invocations, exception handlers, or other points in the
execution of a program.
a) true
b) false
8. When a lazy-initialized bean is a dependency of a singleton bean that is not lazy-initialized, the
ApplicationContext creates the lazy-initialized bean at startup
a) True
b) False
9. Spring DAO framework converts checked exception into unchecked exception. The name of unchecked
exception is________
a) RuntimeException
b) SQLException
c) DataAccessException
d) none of the above
13. The process of applying aspects to a target object to create a new proxy object is called as_____
a) Coupling
b) Weaving
c) Injecting
d) None of the above
15. In order to use @Component annotation for a bean u need to add following tag in Spring bean
configuration file.
a) <context:component-scan>
27
Shriram Mantri Vidyanidhi Info Tech Academy
PG DAC JAVA Technoligies-2 Question Bank
b) <auto:component-scan>
c) <context:bean-scan>
d) None of the above
28