0% found this document useful (0 votes)
1K views

CCP - 1 Spring

1) In Spring AOP, weaving links aspects to objects to create advice. 2) The <list> tag wires a list of values allowing duplicates in Spring. 3) BeanFactory and ApplicationContext act as IoC containers in Spring and provide configuration metadata through XML, annotations, or Java configuration.

Uploaded by

iyy u
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

CCP - 1 Spring

1) In Spring AOP, weaving links aspects to objects to create advice. 2) The <list> tag wires a list of values allowing duplicates in Spring. 3) BeanFactory and ApplicationContext act as IoC containers in Spring and provide configuration metadata through XML, annotations, or Java configuration.

Uploaded by

iyy u
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 38

1) In Spring AOP, the process of linking aspect with other application types or objects to create an advice

object is called ---------Weaving

2) <list> tag is used to wire a list of values, allowing duplicates.

3) BeanFactory, ApplicationContext classes acts as IoC containers in Spring.

4) Can you inject null and empty string values in Spring? ----- yes

5) AOP stands for Aspect Oriented Programming.

6) SpEL is NOT part of core container-------false


Core components of spring ---- core, Bean, context, spEL
Beans, Core, Context,spEL are the components in Core container----------True

7)Following class can be extended to create custom event in spring. ans: ApplicationEvent

8)Which is the way to provide configuration metadata to spring?

A - XML Based configuration file.


B - Annotation based configuration.
C - Java based configuration.
d – all of listed

9) Which of the following are modules of Web layer?


A – Servlet, Web, Portlet
B - WebSocket, Servlet, Web-MVC, Web
C - HTML, JSP, WEB, Portlet
D - HTML, Servlet, WEB, Portlet

10) How many instances can be created for a global session ---- one
11) What display the data with help of model? ----- View

12) Which of the following is correct assertion about spring?


I.Spring enables developers to develop enterprise-class applications using POJOs.
II.Spring is organized in a modular fashion.
III.Testing an application written with Spring is simple
IV. All of the list-----------ANS

13) How after advice works?

A - Run advice after a method execution regardless of its outcome


B - Run advice after a class loads.
C - Run advice after http response is returned.
D - Run advice after http request is processed.

14) What is true about <list> collection configuration elements?

A.This helps in wiring a list of values, allowing duplicates.----------<list>


B.This helps in wiring a list of values but without any duplicates.-----<set>
C.This can be used to inject a collection of name-value pairs where name and value can be of
any type.--------<map>
D.This can be used to inject a collection of name-value pairs where the name and value are
both Strings.----------<props>

15) Element which can be used to inject a collection of name-value pairs where the name and the value can
be of any type.

a)<list>
b)<set>
c)<map>
d)<props>
16) Element which can be used to inject a collection of name-value pairs where the name and the value are
both Strings type.

a)<list>
b)<set>
c)<map>
d)<props>

17) What is ContextStartedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the ApplicationContext is started using the start() method on the
ConfigurableApplicationContext interface.
D - This event is published when the HTTP Response is returned.

18) ContextStartedEvent event is published when the ApplicationContext is started using the start() method
on the ConfigurableApplicationContext interface.-----TRUE

19) ContextClosedEvent--------is published when the ApplicationContext is closed using the close()
method on the ConfigurableApplicationContext interface.-----TRUE

20) Which of the following not available in HQL?


a)Select
b)Where
c)Sub
d)Having

21) Which of the following is an available aggregate function in HQL?


a.Aggregate(property name)
b.Count(property name or *)
c.max(property name)
d.avg(property name)

ANS-sum, avg and count (dont select aggregate)

22) Which of the following database is not supported by Hibernate?

A - DB2/NT
B - MySQL
C - FoundationDB
D - PostgreSQL

23) Which of the following is true about Hibernate?

A - Hibernate is an Object-Relational Mapping(ORM) solution for JAVA


B - Hibernate is an Object-Relational Mapping(ORM) solution for .NET
C - Both of the above.
D - None of the above.

24)ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data
between relational databases.-----------True

25)What is the difference between save() and persist() methods of session object?

A - There is no difference.
B - save saves the object and returns status whereas persist stores status in different variable.
C - save saves the object and returns the id of the instance whereas persist do not return anything
after saving the instance.
D - None of the above.

26) What is required to write a basic spring program? ANS---- jdk, ide, maven, all the above
27) JDBC, ORM, OXM, JMS, Transactions are the modules of Data Access/ Integration layer. ------True

28) Spring framework is a light weight framework. ------TRUE

29) Singleton is the default scope of any spring bean. -----TRUE

30) Analyze the below code snippet:


<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository.JpaDao"/>

Which of the following statements is valid?


I. The "id" attribute must be declared for the bean "MyServiceImpl" because it is mandatory attribute.
II. In the second bean of type "com.spring.repository.JpaDao" the “id" attribute must be specified with
name "jpaDao".

Select One
a. Both I and II are correct
b. II only
c. I only
d. Both I and II are incorrect

a. The first declared bean MyServiceImpl is missing an id must be named myService


b. The second declared bean JpaDao is missing an id must be named jpaDao
c. Answers 1 and 2 are both rights
d. Answers 1 and 2 are both wrong

31) Which of the following parses in XML based on expression and its used extensively in conjugation
with xstl?
a)JDOM parser
b)SAX parser
c) STAX parser
d) Xpath parser

32) What is true about BeanFactory, ApplicationContext?

ANS-BeanFactory is basic and ApplicationContext is advanced

33) Which are the correct implementation classes of ApplicationContext?

A.FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,
WebXmlApplicationContext
B.FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext
C.AdvancedApplicationContext, FileApplicationContext
D.FileSystemApplicationContext, ClassPathApplicationContext

(answers are confusing- xml should be common in those three)

34) org.springframework.web.servlet.DispatcherServlet is the configuration in xml file for


dispatcherServlet.

35) The central artifact in spring javConfig is the @Configuration annotated class?-----True

36) Maven is a project management and comprehension tool-----True

37) What is session scope?


A - This scopes a bean definition to an HTTP session.
B - This scopes the bean definition to Spring IoC container.
C - This scopes the bean definition to HTTP request.
D - This scopes the bean definition to HTTP Application/ Global session

38) What of the following is not correct in live environment?

a. Constuctor and properties autowiring in the same bean are not compatible
b. A bean should have a default or a no-args constructor
c. The <constructor-arg> tag could take type, name and index to reduce ambiguity
d. All of the above

What statement is correct in live environment? Select a unique answer.


1. Constuctor and properties autowiring in the same bean are not compatible
2. A bean should have a default or a no-args constructor
3. The <constructor-arg> tag could take type, name and index to reduce ambiguity
4. All of the above

39) Given the following configuration class, what are correct affirmations? Select one or more answers.
public class ApplicationConfig {
private DataSource dataSource;
@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}
1. @Configuration annotation is missing
2. Default or no-arg constructor is missing
3. @Bean name is ambiguous
4. @Bean scope is prototype

40) ServletWrappingController-Wraps an existing servlet which is managed completely by the spring


environment.---------True

41) [xml]
<id name="deptId" type="string">
<column name="columnid" length="30"/>
<generatoers/>
<id/>
[/xml]
The above is an example of creating which key?

a.DB key
b.Unique key
c.Secondary key
d.Primary key

42) Validations for normal employee class

I. Name cant be empty


I. Id cant be empty
III. Id cant be less than 1
iv. all the above

43) Which of the following is NOT the type of mapping?


a.Instance mapping
b.Component mapping
c.Association mapping
d.Class mapping
44)Around advice------Run advice before and after the advised method is invoked.

Different types of run advice "before" and "after" the advised method is invoked. Which of the following is
the correct option with respect to advice?
a.After returning
b.None
c.After throwing
d.around

Which one runs advice before and after the advised method is invoked.
after
before
around
none of the above

45)HQL- easily stores, update and retrieve from the database--------- True

46)Hibernate is lightweight,opensource and ORM (Multiple choice)

Which of the following is Hibernate?


a.Lightweight
b.Open Source
c.ORM
d.All of the listed

47) Hibernate session is the main runtime interface between java applications and hibernate.-------True

48) When we work with an object oriented system, there is mismatch between the object model and the
relational database.-------True
49) Spring mvc is a model-view-controller.-------True

50) Form fields are validated using user defined validations class by implementing validation interface
State True or False.-------True

51) Spring does not seperate three modules like presentation layer, bussiness layer and data access layer
State True or False.-------False

52) Pick odd one out in the following annotations ( invalid annotations)
I. @PathValid
II. @responsevalid
III. @Controller
IV. @requestmapping

53) Length returns number of rows in a column for only string type.-------True

Length attribute of @column annotation permits the size of the column used to map a value particularly for
a string value.--------true

54) Which level cache implements a cache for query result sets

a. Third level cache


b. Second level cache
c. First level cache
d. Fourth level cache

55) Form tags are available in springs is more compatible with html tags for better development.-------True

56) Which of the following are CORRECT in SQL queries in Hibernate.


I. SQL queries may contain named and positioned parameters, just like Hibernate queries
II. You may express a query in SQL, using createSQLQuery()
III. Hibernate take care of the mapping from result sets to objects
IV. You may call session.connection() and use the JDBC Connection at any time.

a. I, II, and III


b. I, II, and IV
c. I, III, and IV
d. I, II, III, and IV

57) What is the function of clean maven lifecycle command

ANS-cleans artifacts in the earlier build

58) Constructor injection is difficult to inject.-------True

59) Index and type can be used in the constrictor-arg at the same time? -------True

60) Which of the following is a one to one relationship

a) <many-to-many>
b) <many-to-one>
c) None of the list
d) <one-to-many>

61) Which of the following is a many to one relationship

a) many-to-one
b) <many-to-one>
c) None of the list
d) <Manyone>

62) The same XSD of BeanFactory can be used for View resolver interface? -------True

63) Testing an application written with Spring is complex because environment-dependent


code is moved into this framework.---------false

64) What is ContextStoppedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the ApplicationContext is stopped using the stop() method on the
ConfigurableApplicationContext interface.
C - This event is published when the HTTP Request is received.
D - This event is published when the HTTP Response is returned.

65) XsltViewResolver-supports XsltView by resolving the view name of which of the following options

a) all of the listed options


b)VelocityView and its subclasses
c)URL of xslt
d)view name of the URL of the report file.

66) Spring MVC provides predefined templates for JDBC, Hibernate and JPA.---------True

67) ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable

I. MessageSource
II. RequestMapping

a. only I
b.only II
c. Neither I or II
d. Both I and II

68) Which of the following are the best practices for writing spring XML Configurations?

a.Using consistent naming conventions


b. Rarely use classpath
c.Mentioning version numbers in schema references
d.reuse bean definitions as much as possible

69) To validate the form fields you need to have a seperate UserValidator class that implements the
validator interface, Override the validate() method perform all the validations.---------True

70) Which of the listed options are TRUE for Bean configuration inheritance?
I. In spring, Inheritance is supported in bean configuration to share common values, properties or
configurations
II. A child bean or inherited bean can inherit its parent bean configurations, properties and some attributes
III. The parent bean allow to override the inherited values

a.I, II, and III


b.I and II
c.II and III
d.I and III

71) which of the following options about Auto wiring in spring are correct?
I. The Auto wiring in spring framework can be performed by configuring in xml and spring Auto-Wiring
with Annotation @Autowired
II. Auto-wiring beans with xml configuration: In Spring framework, you can wire beans automatically with
auto wiring feature
III. To enable auto-wiring just define the "autowire" attribute in <bean> tag.
a.I, II, and III
b.I and III
c.I and II
d.II and III

72) XML Mapping file offers which of the following?

a.Readable Metadata
b.Surrogate key generation strategy
c.Collecion metadata
d.all the listed options
e.Column/Table Mapping

73) Which of the following explains about addClass function in the listed options
I. This function translates a Java class name into file name
II. This translated file name is then loaded as an input stream from the java class loader
III. This addClass function is important if you want efficient usage of classes in your code

a. I, II, and III


b. I and III
c. I and II
d. II and III

Which of the following explains about addclass function in the listed options?
a.this function translate a java class name into file name
b.this translated file name is then loaded as an input stream from the java class loader
c.this addclass function is important if you want efficient usage of classes in your code

Use of addclass function


it is used to convert java class name into file name
with the file name, input stream, reader will be processed
using add class, other classes will be used efficiently.

74) The application is designed around an object model. The SQL code is generated at build time and the
associations between objects are supported by the persistent mechanism, and queries are specified using an
object oriented expression language. This best suited for medium-sized applications with some complex
transactions. Used when the mappping exceeds 25 different databse products at a time.
Which of the following is this called as?

a. Application Object Mapping


b. Expression object mapping
c. Medium Object Mapping
d. Object Mapping

75) Which of the following is not the best practice?

I.Exit controller has to define in web.xml


II.bean definition
III. open the server and deploy the project
IV.@controller usage

76) What are the modules of spring web flow?


a.Spring-faces
b.Spring-bundling
c.Spring-container
d.Spring-webflow

77) Bean post processor is a concrete class----------false

78) The Spring MVC pattern does not separate the different aspects of the application into input logic,
business logic, and UI logic.-------------------false
Spring MVC provides better way to seperate which of the following?
a.Presentation
b.Tools
c.Data Access
d.Bussiness Logic ----- (bussiness logic,UI login,I/P logic)

79) Constructors in a class can be?


a. may be defined as private
b. Contains same name as class
c. used to create objects
d. all the above

80) Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>

1. The p namespace has to be declared


2. Bean id is bankServiceImpl
3. The BankServiceImpl references a NationalBank bean
4. NationalBank is a scalar value

81) Which is correct?


a. Hibernate is a object oriented query language
b. It is database independent
c. it supports pagination
d. HQL statements will be converted to SQL or other language the database supports
e. all the above

82) Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
1. The execution of all public method
2. The execution of all public method returning a value
3. The execution of all public method having at least one parameter
4. The execution of all public method in class belonging to the default java package

83) What is the transaction behavior of the PROPAGATION_REQUIRES_NEW model? Select a unique
answer.

1. If a transaction exists, the current method should run within this transaction. Otherwise, it
should start a new transaction and run within its own transaction.
2. If a transaction is in progress, the current method should run within the nested transaction
of the existing transaction. Otherwise, a new transaction has to be started and run within its
own transaction.
3. The current method must start a new transaction and run within its own transaction. If there is an
existing transaction in progress, it is suspended.
4. None of the above

PROPAGATION_REQUIRES_NEW----Creates a new transaction, suspending the current transaction if


one exists.

84) Types of autoproxing?


BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator

85) Which scope is a single bean definition to have any number of object instances ? -----prototype

86) Which annotation is used in setter? which type of annotation applies to bean property setter methods
select one
a)@Requires
b)@Resource
c)@Required
d)@Requiring

87) Model is used to encapsulate the response data ------------------True

88) What is a view resolver?


class
interface
object
argument

89) Cache enables the database to hit as much as possible for better performance in critical
applications.----------True

90) View Resolver provides a mapping between view names and actual views.-----------True

91) Which one interpret user input and transform it into a model that is represented to the user by the view.
controller
dispatcher servlet
model
browser

Which of the following handles all the HTTP requests and response?
Ans: Dispatcher Servlet

92) Integration of J2EE with hibernate is difficult.-----------False

93) Application contexts can publish events to beans that are registered as listeners.--------true

94) Which is not used as java annotation


@component
@bean
@configuration
none

95) Hibernate supports query cache-----------true

96) What are the mapping associations used in hibernate?

One-to-One Association
Many-to-One Association
One-to-Many Association
Many-to-Many Association

97) What are the different fetching strategies in hibernate?


1. Join Fetching
2. Batch Fetching
3. Select Fetching
4. Sub-select Fetching
Ans: all

98) Hibernate helps in mapping of java objects with database tables ---------------true

99) Which of the following are mandatory rules to create validation for a normal employee table?
a.The "empNum" cant be empty
b."Name" cant be empty
c.The "empNum" cant be less than 1
d.All of the option

100) Which of the following allows as to add a new method or attributes to existing classes?
a.Introduction
b.Proxy
c.Weaving
d.Auto call

13. Modules of web flow:

management of web applications with complex page flow.

16. Which of the following is true regarding prototype:

a. scope is a single bean definition to have any number of object instances


b. it is the default scope in standard web applications
c. the instances will be created for each bean dependency
d.

28.which mapping is given in hibernate in common?


object
relational
class
column

29.In which level, sql query is integrated in HQL?


class level
low level
high level
object level

34.In which way, the properties of one bean is used by number of beans?
inheritance
dependency injection
through child bean

1. In spring MVC each tag provides support to the set of attributes of its corresponding HTML tag
counterpart making the tags familiar & intuitive to use----------------True
2. We can use index and type attribute together-----------true
3. Which of the following is true about JDBC?
a.JDBC APIs enables java programs to execute SQL statements and interact with any SQL Complaint
database
b.JDBC stands for Java Database Connectivity
c.it provides set of java API for accessing the relational databases from java program
d.All the listed option

4.Which of the listed statement are correct for spring Bean scope:Prototype?

a.Spring container creates new instance of bean for each and every request for that bean-------------
b.Prototype scoped bean is served by creating new instance of bean for each and every bean
dependency----------
c.After instatiating bean and submitting it to client spring container will maitain the record(not maintain)
d.Prototype scope is spring standard scope and can be used in standalone as well as web application of
spring.------

5. Which is the query language that embodies a very powerful and flexible mechanism to query, store,
update and retrive
objects from a database?
a.PLSQL
b.RDBMS
c.SQL
d.HQL

6. What is spring MVC framework?


a.spring MVC framework is used for Transaction management for web application
b.spring MVC framework is Model-value-class architecture and used to bind model data
c.spring MVC framework is used for AOP for web application
d.spring web MVC framework provides model-view-controller architecture and ready components
that can be used to develop flexible and loosely coupled web applications

7.When you need to upload a large number of records into your database using Hibernate, you can use
batch processing.------true

8. Implementation of viewResolver accets a configuration file written in XML with the same DTD as
spring XML bean factories.---------true

9.For a fast Development, the dependency injection feature of spring Framework & support to various
Frameworks makes the easy development of javaEE application.-------true

10. In hibernate implement cache for a query ,if the result sets can integrate closely,which level
of the cache can be implemented?
a.first level cache
b.second level cache
c.third level cache
d.Fourth level cache

11. In Spring MVC which of the following is the front controller class that initializes the context
based on the spring beans configuration?
a.org.springframework.web.servlet.DispatcherServlet
b.org.springframework.web.context.DispatcherServlet
c.org.springframework.web.servlet
d.org.springframework.web.context.ApplicationContext

12. Which of the following statements are correct?


a.Bean Factory and ApplicationContext are basic container only
b.Bean Factory is basic container and ApplicationContext is advanced container
c.Bean Factory and ApplicationContext are advanced container
d.Bean Factory is advanced container and ApplicationContext is basic container

13. In spring bean configuration bean atribute called 'scope' defines what kind of object
has to be created and returned. What returns a new bean instance each time when required?
a. Prototype
b.Session
c.Singleton
d.Global session

14. What is ContextClosedEvent event?


A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the HTTP Response is returned.
D - This event is published when the ApplicationContext is closed using the close method on the
ConfigurableApplicationContext interface.

15. Spring MVC provides a JSP tag library(Spring form) for making it easier to bind form elements to
model data.-------True

16. Which of the following statement is INCORRECT by extending ViewResolver and


ChainingViewResolver?
a. programmers can have custom view resolvers
b. There are lot of view resolvers available in Spring framework
c. Spring MVC view resolvers help the Dispatcher Servlet in identifying the views which has to be
rendered in response for a request.
d.none

17. What are the benefits of Spring Framework's transaction management?


a.It Provides a consistent programming model across different transaction APIs such as JTA, JDBC,
Hibernate, JPA, and JDO.
b.It Supports declarative transaction management.
c.It Provides a simpler API for programmatic transaction management than a number of complex
transaction APIs such as JTA.
d.All the listed

18. It is difficult to inject the dependency by constructor. ------------true

19. The Model-View-Controller(MVC) is an architectural pattern that does not separate an application into
three main logical compponents: the model,the view and the controller.------false

20. How many layers are there in Hibernate architecture


a) 3
b) 4
c) 5
d) 2

21. Which tool helps to generate the mapping document Though many Hibernate users choose to write the
XML by hand
select one
a)oldgen
b)younggen
c)Middlegen
d) Mediumgen
22. Java based configuration option disables you to write most of your Spring configuration without XML
but with the help of few Java-based annotations ----------------False

23. What types of views supported by spring MVC for different presentation technologies
select one or more
a)JSP
b)HTML
c)velocity templates
d) all

24. Spring is a heavy weight framework---------------False

25. A very powerful and high performance qurerying language used to Query,retrive,store data in DB is
select one
a) PLSQL
b) HQL
c) SQL
d) RDBMS

26. Which best describes the propagation attribute REQUIRED?


Create a new transaction, suspend the current transaction if one exists.
Execute non-transactionally, suspend the current transaction if one exists.
Supports a current transaction, throw an exception if none exists
Support a current transaction, create a new one if none exists.

27. Which best describes the propagation attribute NON_SUPPORTED?

a. Create a new transaction, suspend the current transaction if one exists.


b. Execute non-transactionally, suspend the current transaction if one exists.
c. Supports a current transaction, throw an exception if none exists.
d. Support a current transaction, create a new one if none exists.

28. Which best describes the propagation attribute MANDATORY?

Create a new transaction, suspend the current transaction if one exists.


Execute non-transactionally, suspend the current transaction if one exists.
Supports a current transaction, throw an exception if none exists.
Support a current transaction, create a new one if none exists.

29. Which best describes the propagation attribute REQUIRES_NEW?

Create a new transaction, suspend the current transaction if one exists.


Execute non-transactionally, suspend the current transaction if one exists.
Supports a current transaction, throw an exception if none exists.
Support a current transaction, create a new one if none exists.

30. Can you instiantiate a static inner class in Spring?

No, static classes are not supported


Yes, they are instiantiated by default with the class.

31. An application server is required for spring's transaction mechanism to run.

TRUE
FALSE

32. What are the types of injection supported by Spring?

Constructor Injection only.


Constructor Injection and Setter Injection
Constructor Injection, Setter Injection and Interface Injection
Constructor Injection, Setter Injection before 2.0 and Interface Injection with 2.0 and above version
33. @Inject annotation supports "required" attribute.

TRUE
FALSE

34. Which event is published when context is initialized?

ContextStartedEvent
. ContextRefreshedEvent
ContextInitializedEvent
ContextReadyEvent

35. Which event is published when context is refreshed?

ContextStartedEvent
ContextInitializedEvent
ContextReadyEvent
. ContextRefreshedEvent

36. Spring Web MVC (and in Spring in general) is the "Open for extension, closed for modification"
principle.
The reason that this principle is being mentioned here is because a number of methods in the core classes in
Spring Web MVC are marked final.

true
false

37. Which of the among is not a special bean in WebApplicationContext?


Locale resolver
Theme resolver
multipart file
resolver
Handler exception resolver
Handler mappings
None of the above

38. How the Spring DispatcherServlet supports for returning the last-modification-date, as specified by the
Servlet API ?

By implementing the LastModified interface


By implementing the LastSessionModified interface
By implementing the LastDateModified interface
By implementing the LastModifiedDate interface

39. WebApplicationContext has more scopes like request, session, globalSession to the standard
Application context (which only provides Singleton and Prototype scopes)-----------true

40. All of Spring's various Controller inherit from AbstractControllor?--------true

41. You can write your own controller by using handleRequestInternal(HttpServletRequest,


HttpServletResponse) method from abstract controller and a ModelAndView object.-----true

42. Which of the following controller inspects the URL and retrieves the filename of the file request and
uses that as a viewname ?For example, the filename of http://www.springframework.org/welcome.html
request is welcome.

UrlFilenameViewController
MultiActionMultiActionController
CommandController
AbstractController

43. The available prefixes for ClassPathXmlApplicationContext look up are:-

classpath:
file:
http:
https:

44. Spring event mechanism is based on the standard:-

Observer Design Pattern


Factory Design Pattern
Mediator Design Pattern

45. What kind of servers can support Spring Transaction?


Only Application servers
Only Application servers which support J2EE specification
Spring's transactional services are supported on web servers also

46. In Spring Framework's declarative transaction implementation, is it sufficient to annotate to classes


with the @Transactional annotation? -------------NO

47. What is dependency injection?

A design pattern where dependent objects are defined in an xml for easy maintainability.
This is a design pattern whereby dependent objects are passed into an object from the outside at the
time application is initialized.
A unique feature of spring which allows object to be injected at the time of compilation.

48. Given following controller :-


@RequestMapping("/basket")
@Controller
public class Shopping {
@RequestMapping("/{id}")
public String doCheckOut(@PathVariable Date time) {
return "home";
}
}
Is declaration of Shopping#doCheckOut method correct?------------TRUE

49. If you were using Join Points, Pointcuts & Advice what would you be using?

Bean Contatiner
JPA
EJB
AOP

50. Spring 3.0 does not support for multipart form. -------False

51. Which of the following view technologies are supported by Spring?

JSTL/JSP
Ms Excel
Adobe PDF
All of the above.

52. Spring 3.0 provides the PropertyEditor for performing thread-safe type conversion. This allows any
Type to be converted to any other Type. -------------FALSE
53. For a given web.xml configuration:
<web-app version="2.5">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Which path should has file that contains XML configuration metadata for ApplicationContext of given
DispatcherServlet?

/WEB-INF/application-context.xml
/dispatcher-servlet.xml
/WEB-INF/dispatcher-servlet.xml

54. Suppose I have an aspect:


@Before("execution(* method*()")
and the following class:
public class MyClass() {
public void method1() {
method2();
}
public void method2() {
}
}
If I call, myClass.method1(), from another class, which methods does the advice run against?
method1
method2
neither
both

55. The following methods :-

queryForInt(args)
queryForList(args)
getJdbcOperations()
getNamedParameterJdbsOperations()
are all present in which of the following class?

SimpleJdbcTemplate
JdbcTemplate
NamedParameterJdbcTemplate
None of the above

56. The dynamic languages currently supported by Spring are:-

Groovy
JRuby
BeanShell
All the above
57. JMS stands for-
Java Message Service
Java Mechanism Service
Java Message System
Java MultiThreaded System
58. Which of the following tag is used to enable Aspect using XML configuration?

<aop:aspectj-autoproxy/>
<aop:aspectj-component/>
<aop:aspectj/>
<aop:aspectj-autoproxy-component-scan/>

59. Programatic transaction management is done using:-

TransactionTemplate
PlatformTransactionManager
@TransactionManager
IntegratedTranaction

60. Which of the following are valid return types, or values, from a controller implementation?

null
A String view name
void
All of the above

61. Which of the following are JSR - 250 annotation/s?

@PreConstruct
@PreDestroy
@Resource
@PostConstruct
@Autowired
@Controller
62. In Spring's form tag library which of the following tags are valid?

input and inputs


checkbox and checkboxes
radiobutton and radiobuttons
redirect

Solution
checkbox and checkboxes are valid spring tags.
radiobutton and radiobuttons are valid spring tags.
input is valid spring tag but inputs is not a valid spring tag.

63. If you want to provide the MessageSource functionality to application, providing access to messages in
i18n-style in your application. Which one should be used?

ApplicationContext
Property File
Servlet Context

64. Can dependency injection be lazy initialized?

YES
NO

Solution
Using lazy-init="true" in spring configuration file on the bean, it can be instantiated only when needed.

65. Which of the following is the correct way to use @Transactional annotation in spring?

Ans.
@Service
class OrganizationService{
@Transactional(readOnly = false)
public void saveData(Employee emp){
}
}

Ans.
@Service
class OrganizationService{
@Transactional(readOnly = true)
public void getData(Employee emp){
}
}

Ans.
@Service
class OrganizationService{
@Transactional
public void saveData(Employee emp){
}
}

@Service
class OrganizationService{
@Transactional = readOnly(false)
public void saveData(Employee emp){
}
}
@Service
class OrganizationService{
@Transactional = readOnly(true)
public void saveData(Employee emp){
}
}

1. What is the type of file used for spring configuration?


Ans:
 XML based configuration file.
 Annotation-based configuration
 Java-based configuration

2. What are the types of autowire?


ANS: no, byName, byType, constructor, autodetect

3. What is the security annotation used in spring? (@autowire, @transicible ,……)


Ans : @PreAuthorize and @PostAuthorize

4. What are the types of editors used in spring framework?


Ans:
 PropertyEditor
 URLEditor
 ClassEditor
 CustomDateEditor
 FileEditor
 LocaleEditor
 StringArrayPropertyEditor
 StringTrimmerEditor
5. What is the use of ‘after return advice’?
Ans : Advice that is executed after the normal completion of a joinpoint is called the “after
returning advice”.
6. What are the things mapped in an XML? (Data type, value ,….)

Qns-1: Describe Global and Local transactions in Spring.

Ans: Global transactions help to work with multiple transactional resources like relational database and
message queue.
Global transactions are managed through JTA and JNDI. Local transactions are resource-specific like
JDBC connection.
Local Transactions can work with multiple transactional resources.

Qns-2: What is the role of TransactionDefinition interface?


Ans: a. Isolation
b. Propagation
c. Timeout
d. Read-only status

Qns-3: How can we roll back a declarative transaction?


Ans: We can use rollback-for and no-rollback-for attributes with transactional definition.

Qns-4: How many types of isolation are there?


Ans: a. ISOLATION_DEFAULT: default isolation.
b. ISOLATION_READ_COMMITTED: dirty reads are prevented, non-repeatable and phantom reads are
allowed.
c. ISOLATION_READ_UNCOMMITTED : dirty reads are allowed, no-repeatable and phantom reads are
allowed.
d. ISOLATION_REPEATABLE_READ: dirty reads and non-repeatable reads are prevented but phantom
reads are allowed.
e. ISOLATION_SERIALIZABLE : dirty , non- repeatable reads and phantom reads are prevented.
Qns-5: How many types of Propagation are there?
Ans: Find the Propagation type. a. PROPAGATION_MANDATORY : supports current transaction and
throws exception if no transaction available.
b. PROPAGATION_NESTED : runs with nested transaction
c. PROPAGATION_NEVER : does not run with current transaction and throws exception if current
transaction exits.
d. PROPAGATION_NOT_SUPPORTED : runs non -transactionaly and does not support current
transaction.
e. PROPAGATION_REQUIRED : runs with current transaction and create one if does not exist.
f. PROPAGATION_REQUIRES_NEW : creates new transaction and suspends if exits any.
g. PROPAGATION_SUPPORTS: runs current transaction and runs non -transactionaly

You might also like