Spring Updated
Spring Updated
4) Can you inject null and empty string values in Spring? -----yes
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>
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.
27)JDBC, ORM, OXM, JMS, Transactions are the modules of Data Access/ Integration layer.------True
35) The central artifact in spring javaConfig is the @Configuration annotated class?-----True
44)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
45)HQL- easily stores, update and retrieve from the database--------- True
48) When we work with an object oriented system, there is mismatch between the object model and the
relational database State True or False
a) TRUE
b) FALSE
50) Form fields are validated using user defined validations class by implementing validation interface
State True or False.-------True
51) Spring does not separate three modules like presentation layer, business 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
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
62) The same XSD of BeanFactory can be used for View resolver interface?
State True or False
a) TRUE
b) FALSE
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 separate 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
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.
73) Which of the following explains about addClass function in the listed options(doubt)
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
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.
78) The Spring MVC pattern does not separate the different aspects of the application into input logic,
business logic, and UI logic.-------------------false
80) Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>
a) The p namespace has to be declared
b) Bean id is bankServiceImpl
c) The BankServiceImpl references a NationalBank bean
d) NationalBank is a scalar value
82) Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
a) The execution of all public method
b) The execution of all public method returning a value
c) The execution of all public method having at least one parameter
d) 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.
a) 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.
b) 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.
c) 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.
d) None of the above
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
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.
a) controller
b) dispatcher servlet
c) model
d) browser
92) Assuming @Transactional annotation support is enabled and the transferMoney method is called
through a Spring AOP proxy, what is the behavior of the following code sample?
@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}
a) The add() method executes code in a new transaction
b) The add() method uses the transaction of the transferMoney() method
c) When calling the add() method, an exception is thrown
d) Other behavior
93) Application contexts can publish events to beans that are registered as listeners.--------true
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
111. Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value.--------true
116.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
117.We can use index and type attribute together-----------true
120.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
122.When you need to upload a large number of records into your database using Hibernate, you can use
batch processing.------true
123.Implementation of viewResolver accets a configuration file written in XML with the same DTD as
spring XML bean factories.---------true
124.For a fast Development, the dependency injection feature of spring Framework &support to various
Frameworks makes the easy development of javaEE application.-------true
125.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
126.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
128.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
129. Which of the following is true about Hibernate?
A) Hibernate takes care of mapping Java classes to database tables using XML files and without writing
any line of code.
B)Hibernate provides simple APIs for storing and retrieving Java objects directly to and from the database.
C)Hibernate abstracts away the unfamiliar SQL types and provide us to work around familiar Java Objects.
D)All of the above.
130.Spring MVC provides a JSP tag library(Spring form) for making it easier to bind form elements to
model data.-------True
132. Spring MVC provides better way to separate which of the following?
a.Presentation
b.Tools
c.Data Access
d.Bussiness Logic(not sure)
134.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
135. How many layers are there in Hibernate architecture
a)3
b)4
c)5
d)2
136. 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
137. 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
138. 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
140. 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
151. 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.
a. true
b. false
152. Which of the among is not a special bean in WebApplicationContext?
a. Locale resolver
b. Theme resolver
c. multipart file
d. resolver
e. Handler exception resolver
f. Handler mappings
g. None of the above
153. How the Spring DispatcherServlet supports for returning the last-modification-date, as specified by
the Servlet API ?
154. WebApplicationContext has more scopes like request, session, globalSession to the standard
Application context (which only provides Singleton and Prototype scopes)-----------true
157. 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.
a. UrlFilenameViewController
b. MultiActionMultiActionController
c. CommandController
d. AbstractController
a)A design pattern where dependent objects are defined in an xml for easy maintainability.
b)This is a design pattern whereby dependent objects are passed into an object from the
outside at the time application is initialized.
c)A unique feature of spring which allows object to be injected at the time of compilation.
@RequestMapping("/basket")
@Controller
public class Shopping {
@RequestMapping("/{id}")
public String doCheckOut(@PathVariable Date time) {
return "home";
}
}
Is declaration of Shopping#doCheckOut method correct?------------TRUE
164. If you were using Join Points, Pointcuts & Advice what would you be using?
a)Bean Contatiner
b)JPA
c)EJB
d)AOP
167. Spring 3.0 provides the PropertyEditor for performing thread-safe type conversion. This allows any
Type to be converted to any other Type.-------------FALSE
/WEB-INF/application-context.xml
/dispatcher-servlet.xml
/WEB-INF/dispatcher-servlet.xml
173. Which of the following tag is used to enable Aspect using XML configuration?
a)<aop:aspectj-autoproxy/>
b)<aop:aspectj-component/>
c)<aop:aspectj/>
d)<aop:aspectj-autoproxy-component-scan/>
175. Which of the following are valid return types, or values, from a controller implementation?
a)null
b)A String view name
c)void
d)All of the above
177. In Spring's form tag library which of the following tags are valid?
a) input and inputs
b) checkbox and checkboxes
c) radiobutton and radiobuttons
d) 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.
178. 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?
a) ApplicationContext
b) Property File
c) Servlet Context
182. What is the security annotation used in spring? (@autowire, @transicible ,……)
Ans :@PreAuthorize and @PostAuthorize
185. What are the things mapped in an XML? (Data type, value ,….)
186. 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.
192.Name attribute of @Column annotation permits the name of the column to be explicitly specified.
a) true
b) false
193. which of the following Allows you to add new methods or attributes to existing classes?
a.Advice
b.Join point
c.Aspect
d.Pointcut
e.Target object
f.Weaving
g.Introduction
200. Beans, Core, Context, SpEL are the modules of core container.
a) true
b) false
203. Run advice before and after the advised method is invoked.
ans. around advice
204. Length attribute of @Column annotation permits the size of the column used to map a value
particularly for a String value.
A) false
B )true
209. Given the following Spring configuration file, what is the correct answer:
<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository.JpaDao"/>
i. The first declared bean MyServiceImpl is missing an id must be named
myService
ii. The second declared bean JpaDao is missing an id must be named
jpaDao
iii. Answers 1 and 2 are both rights
iv. Answers 1 and 2 are both wrong
220. which of the following are the concerns which are needed in almost every module of an application
a)logging
b)security
c)data transfer
221. Hibernate is the open object relational mapping tool for java.
a)true
b)false
225. 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
226. The central artefact in spring javConfig is the @Configuratuion annotated class?State True or False
a) TRUE
b) FALSE
231. 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. State true or False.
a) True
b) false
234. Length returns number of rows in a column for only string type
a). TRUE
b). FALSE
235. The view interface inhibits the preparation of request and hands the request over to one of the view
technologies in spring. State true or false
a)true
b)false
236. The data required for the request is in which part of spring MVC component?
a)model
b)view
c)controller
d)all
240. To use Hibernate for multiple databases, Configure multiple sessionFactory instances. State True or
False.
a) True
b) False
242.Which scope is a single bean definition to have any number of object instances
Prototype
243. @RequestMapping annotation is used to map a URL either an entire class or to particular handler
method
a) True b) False
245. which of the following method returns the root element of the document in DOM parsing?
a) Node.getFirstChild
b) Node.getLastChild
c) Document.getDocumentElement
d) Node.getRoot
247. 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>
253. In how many ways, objects can be fetched from database in hibernate?
Hibernate provides following four ways to fetch objects from database:
a. Using HQL
b. Using identifier
c. Using Criteria API
d. Using Standard SQL
254.You would need one session factory object per database using a separate config file.
a) TRUE
b) FALSE
258. does sessionLocaleResolver interceptor detects if a special parameter is present in current Http req?
No
259. Which of the following are true about ‘clean' maven life cycle
a.used to build the application
b.generates site documentaion for the project
c.cleans up artefacts created by prior builds
d.none
261. Which clause allows you to narrow the list of instances returned?
a) Aggregate function
b) Where clause
c) Select clause
d) joins
b) FALSE
263. Which of the following great future if you can manage in long term?
A) constructor injection
B) schema mapping
C) classpath prefix
D) autowiring
264. Session.beginTransaction method begins a unit of work and returns the associated Transaction object.
A) true
B)false
265. How many bean scopes are specified in singleton by default?
a.6
b.7
c.5
d.none
266. Hibernate inhibits you to express queries in its own portable SQL extension (HQL)as well as in native
SQL ,or with an object oriented criteria
a)true
b)False
267. Tags generated by form tag lib are compliant with xhtml-1.0 strict specification and attendant dtd.
a) True
b) false
268. Archetype is a maven plugin whose task is to create a project structure as per its template
c) True
d) false
271. Named queries are created via which level of annotations on entities?
a.all-level
b.high-level
c.low
d.class level
273. What is the difference between get() and load() methods of session object?
A) get() returns null if no data is present where as load throws ObjectNotFoundException exception in such
case.
B)get() always hits the database whereas load() method doesn't hit the database.
C)get() returns actual object whereas load() returns proxy object.
D)All of the above.
274. The test module supports the testing of spring components with junit for testing
a) True
b) false
275. In controller which is responsible for rendering the page in spring mvc(not sure)
a.browser
b.http
c.database
d.application
281.The Spring MVC pattern does not separate the different aspects of the application into input logic,
business logic, and UI logic.
a) true
b) false
287. Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
a. The execution of all public method
b. The execution of all public method returning a value
c. The execution of all public method having at least one parameter
d. The execution of all public method in class belonging to the default java package
288. Identify the annotation which simply indicates that the affected bean property must be populated at
configuration time, through an explicit property value in a bean definition or through autowiring. The
container throws BeanInitializationException if the affected bean property has not been populated.
@Required
291 Session.createQuery creates a new instance of Query for the given HQL query string.
A) True
B)False
292. 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.
301. Which of the following is true about transient state of a persistent entity?
A) A new instance of a persistent class which is not associated with a Session
B)A new instance of a persistent class which has no representation in the database.
C)A new instance of a persistent class which has no identifier value.
D)All of the above.
302. Which method is used to re-read the state of the given instance from the underlying database?
A) Session.refresh()
B)Session.get()
C)Session.reload()
D)Session.retrieve()
304. Child objects are not loaded when parent is loaded/populated from database. What this technique is
called?
A) Eager Loading
B)Lazy Loading
C)Request based Loading
D)None of the above.
306. Form tags are available in springs is more compatible with html tags for better development
State True or False
a) true
b) false
309. Which of the following is true about hibernate. Dialect property in hibernate configuration?
A) This property makes Hibernate generate the appropriate SQL for the chosen database.
B)This property makes Hibernate generate the appropriate java code for the chosen database.
C)Both of the above.
D)None of the above.
310. Which method is used to save the state of the given instance from the underlying database?
A) Session. Store ()
B)Session. Keep ()
C)Session. Save ()
D)Session. Load ()
312. Configure single sessionFactory per database, using separate configuration file.
a) True
b) False
322. Which of the following object is used to create SessionFactory object in hibernate?
A) Configuration
B)Session
C)SessionFactory
D)Transaction
326. Which of the following class can be used to execute Sql queries in spring?
A)JdbcTemplate
B) JDBCHelper
C)DBHelper
D)DBTemplate
335. Which class is used to map a database row to a java object in spring?
A) ResultSet
B)RowMapper
C)RowSetMapper
D)ResultSetMapper
342. Expression Language/ SpEL was introduced in which version of spring framework.
A) 1.0
B)2.0
C)3.0
D)4.0
343. What are the main advantage(s) for using Spring when writing integration tests?
a) Reuse Spring configuration files of the application
b) Create mock or stub
c) Be able to use the rollback after the test pattern
d) Use dependency injection
345. What are the different points where weaving can be applied?
A) Compile time, load time
B)Compile time, run time
C)Run time
D)Compile time, load Time, Run time
346. Which of the following is part of Data Access layer in Spring framework?
A) Beans
B)Aspects
C)JMS
D)Context
352. What are the types of the transaction management Spring supports?
A) Programmatic transaction management
B)Declarative transaction management
C)Both of above.
D)None of above.
357. Select the right statement about referring a Spring configuration file inside the package
com.example.myapp in the below example?
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");(checkbox ques)
a) The classpath: prefix could be omit
b) Package name with dot is not well formatted using the dot character
c) The slash character preceding com.example could be omit
d) All of the above
e) None of the above
366. What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?
a) In a web application
372. Hibernate session is the main runtime interface between java applications and hibernate.
a) TRUE b) FALSE
373. Which of the following is true about @Column annotation?
A) The @Column annotation is used to specify the details of the column to which a field or property will
be mapped.
B)The @Column annotation is applied on a class.
C)Both of the above.
D)None of the above.
377. Application contexts provide a generic way to load file resources, such as images.
a) True
b) False
378. What is easier to do by using Spring JMS support? Select one or more correct answers.
a. Register any Spring bean as JMX MBean
b. Register an existing MBean with a MBeanServer
c. Accessing to remote MBean
d. Control the attributes and the operations of a Spring bean exposes as a MBean
385. Which of the following class can be used to call Stored Procedures in spring?
A) SPHelper
B)JdbcTemplateCall
C)JdbcTemplate
D)SimpleJdbcCall
386. Which element of hbm.xml is used to map a Java class property to a column in the database table?
A) id
B)generator
C)property
D)class
389. Cache is simply to enhance the performance and it sits between application and database.
a) True
b) False
391. Scope that are used only in web aware application context
Request
Session
Global session
398. Session.createSQLQuery creates a new instance of Query for the given SQL query string.
A) true
B)false
399. Which method is used to get a persistent instance from the datastore?
A) Session.read()
B)Session.get()
C)Session.retrieve()
D)Session.fetch()
401. Which of the following element is used to represent one-to-many relationship in hibernate?
A) <one-to-many>
B)<one-many>
C)<OneToMany>
D)None of the above.
407. Which method is used to remove a persistent instance from the datastore?
A) Session.delete()
B)Session.remove()
C)Session.del()
D)Session.rm()
408. Which method is used to save or update the state of the given instance from the underlying database?
A) Session.saveOrUpdate()
B)Session.keep()
C)Session.update()
D)Session.load()
413. How could you implement a JMS Listener using the Spring JMS support? Select one or more correct
answers.
a. By implementing the javax.jms.MessageListener interface
b. By implementing the SessionAwareMessageListener interface provided by Spring
c. Without any code, only using the jms namespace provided by Spring
d. By writing a single POJO without parent class or interface
415. What do you have to do even if you are using the RMI Spring Remoting support? Select one or more
correct answers.
a. Implements the Remote interface
b. Extends the RemoteObject class
c. Catching the RemoteException exception
d. Implements the Serializable interface
418. Which one interpret user input and transform it into a model that is represented to the user by the
view.
a) controller
b) dispatcher servlet
c) model
d) browser
419. Which one runs advice before and after the advised method is invoked.
a) after
b) before
c) around
d) none of the above
420. Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value.
a) true b)false
421. Application contexts can publish events to beans that are registered as listeners.
a)true
b)false
424. To use spring MVC validator, which of the following is used to start the validator?- ve to select more than
1 so I chose al the check box..
A) override supports
B) override validate
C) override validator
D) override creates
425. index and type can be used in the constructor-arg at the same time?
State True or False
a)TRUE
b) FALSE
430. What is exact about the HttpInvokerServiceExporter? Select one or more correct answers.
a. Has to run into a HTPP server as Jetty
b. Could process both POST and GET requests
c. Could be used with any http client as Jakarta Commons HttpClient
d. Could consume SOAP http request
431. What is the method that is not provided by the JmsTemplate Spring class?
a. convertAndSend
b. onMessage
c. receiveAndConvert
d. setDefaultDestination
432. How is named the bean that is defined in the following configuration class. Select a single answer.
@Configuration
public class ApplicationConfig {
@Autowired
private DataSource dataSource;
@Bean
ClientRepository clientRepository() {
ClientRepository accountRepository = new JpaClientRepository();
accountRepository.setDataSource(dataSource);
return accountRepository;
}
}
1. JpaClientRepository
2. jpaClientRepository
3. clientRepository
4. Two beans are defined : a data souce and a repository
433. How could you externalize constants from a Spring configuration file or a Spring annotation into a
.properties file? Select one or more answers
a. By using the <util:constant /> tag
b. By declaring the ConstantPlaceholderConfigurer bean post processor
c. By using the <context:property-placeholder /> tag
d. By using the c: namespace
434. What is the purpose of the @ManageResource annotation? Select a single answer.
a. Expose a bean’s property (getter/setter) to JMX
b. Expose a bean’s method to JMX
c. Identify a Spring bean as a JMX MBean
d. None of the above
435. What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy
annotations?
a. Those annotations are specified in the JSR-250
b. The Spring Framework embedded those annotation
c. The <context:component-scan> tag enable them
d. The <context:annotation-config > tag enable them
e. Declaring the CommonAnnotationBeanPostProcessor enable them
436. What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?
a. In a web application
b. In an integration test running with the SpringJUnit4ClassRunner
c. In a standalone application started with a main method
d. None of the above
437.Select the right statement about referring a Spring configuration file inside the package
com.example.myapp in the below example?
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");
a) The classpath: prefix could be omit
b) Package name with dot is not well formatted using the dot character
c) The slash character preceding com.example could be omit
d) All of the above
e) None of the above
438. How to auto-inject into a field a bean by its name? Select one or more response.
a) With the name attribute of the @Autowired annotation
b) By using the single @Qualifier annotation
c) By using both the @Autowired and the @Qualifier spring annotations
d) By using the @Autowired annotation and naming the field with the bean name
439. What are the main advantages of using interfaces when designing business services? Select one or
more answers.
a. Mocking or stubbing the service
b. Be able to use the Spring auto-injection
c. Can do dependency checking
d. Loosely coupled code
440. Select one or many correct answers about spring bean life cycle.
1. The method annoted with @PostConstruct is called after bean instantiation and before
properties setting of the bean
2. The method @PreDestroy of a prototype bean is called when the bean is garbage collected
3. The init() method declared in the init-method attribute of a bean is called before the
afterPropertiesSet callback method of the InitializingBean interface
4. The method annotated with @PostConstruct is called before the afterPropertiesSet
callback method of the InitializingBean interface
441. 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();
}
}
a. @Configuration annotation is missing
b. Default or no-arg constructor is missing
c. @Bean name is ambiguous
d. @Bean scope is prototype
442. What are the features of the XML <context: namespace? Select one or many answers.
1. @Transactional annotation scanning
2. @Aspect annotation detection enabling
3. @Autowired annotation enabling
4. @Component annotation scanning
443. Select one or more correct statements about developing integration test with Spring support.
a) A new Spring context is created for each test class
b) To get a reference on the bean you want to test, you have to call the getBean() method of
the Spring context
c) Spring context configuration could be inherits from the super class
d) The Spring context configuration file has to be provided to the @ContextConfiguration annotation
444.What are the main advantage(s) for using Spring when writing integration tests?
a. Reuse Spring configuration files of the application
b. Create mock or stub
c. Be able to use the rollback after the test pattern
d. Use dependency injection
445.What are the main advantage(s) for using Spring when writing unit tests?
a. Reuse Spring configuration files of the application
b. Use dependency injection
c. Provide some mocks for servlet classes
d. All of the above
e. None of the above
447.Select correct statement(s) about transactional support of the spring test module.
1. Transaction manager could be set within the @TransactionConfiguration annotation
2. Method annotated with @Before is executed outside of the test’s transaction
3. Spring test may rollback the transaction of a service configured with the REQUIRES_NEW
propagation
4. The transaction of a method annotated with the @Rollback annotation with its default
values is rolled back after the method has completed
448. Considering 2 classes AccountServiceImpl and ClientServiceImpl. Any of these 2 classes inherits from
each other. What is the result of the pointcut expressions?
execution(* *..AccountServiceImpl.update(..))
&& execution(* *..ClientServiceImpl.update(..))
1. Matches pubic update methods of the 2 classes, whatever the arguments
2. Matches any update methods of the 2 classes , whatever the arguments and method
visibility
3. Matches any update methods of the 2 classes , with one more arguments and whatever
method visibility
4. No joint point is defined
449. Using the Spring AOP framework, what is the visibility of the method matches by the following join
point?
@Pointcut("execution(* *(..))")
private void anyOperation() {};
1. All methods, whereas there visibility
2. All methods, except private method
3. Protected and public methods
4. Public methods
505. Select method’s signatures that match with the following pointcut:
execution(* com.test.service..*.*(*))
1. void com.test.service.MyServiceImpl#transfert(Money amount)
2. void com.test.service.MyServiceImpl#transfert(Account account, Money amount)
3. void com.test.service.account.MyServiceImpl#transfert(Money amount)
4. void com.test.service.account.MyServiceImpl#transfert(Account account, Money amount)
5. None of the above
506. What are the unique correct answers about Spring AOP support?
1. An advice could proxied a constructor’s class
2. A point cut could select methods that have a custom annotation
3. Static initialization code could be targeted by a point cut
4. Combination of pointcuts by &&, || and the ! operators is not supported
507.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
508.Why is it a best practice to mark transaction as read-only when code does not write anything to the
database? Select one or more answers.
1. It is mandatory for using Spring exception translation mechanism
2. May be improve performance when using Hibernate
3. Spring optimizes its transaction interceptor
4. Provides safeguards with Oracle and some other databases
509.What data access technology is supported by the Spring framework? Select one or more answers.
1. JDBC
2. NoSQL
3. Hibernate
4. JPA
513.What is/are incorrect statements about XML declaration of the transaction manager bean? Select
one or more answers.
1. The tx namespace provides JTA transaction manager declaration shortcut syntax
2. Id of the bean has to be transactionManager
3. Depending the application persistence technology, the HibernateTransactionManager or the
DataSourceTransactionManager could be used as bean class
4. Default transaction timeout could be given
514. Assuming @Transactional annotation support is enabled and the transferMoney method is called
through a Spring AOP proxy, what is the behavior of the following code sample?
@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}
a. The add() method executes code in a new transaction
b. The add() method uses the transaction of the transferMoney() method
c. When calling the add() method, an exception is thrown
d. Other behavior
515. Does Spring provides programmatic transaction management? Select a unique answer.
a. Yes with the TransactionTemplate class
b. Yes with the TransactionService class
c. Yes using the @Transactional bean post processor
d. No
516. What is the transaction behavior of the PROPAGATION_REQUIRES_NEW mode? 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
518. What could not return a Spring MVC controller? Select a single answer.
a. An absolute path to the view
b. A logical view name
c. A new JstlView
d. void
e. null value
519. Where do you cannot declare Spring MVC controller? Select one or more answers.
1. In a Spring application context XML configuration file
2. Into the web.xml file of the web application
3. Into the java code by using annotations
4. Into the JSP pages
521.How could you secure MVC controller with Spring Security? Select a unique answer.
a) With the @Secured annotation
b) With the @RolesAllowed annotation
c) In a XML security configuration file
d) All of the above
e) None of the above
522. What are the possible mechanisms provided by Spring Security to store user details? Select one or
more correct answers.
a. Database
b. JAAS
c. LDAP
d. Properties file
523. What is true about Spring security configuration and the security namespace? Select one or more
correct answers.
a. The access attribute of the intercept-url tag support both EL and constants together.
b. The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is
b) the first that matches.
a. The patterns declared into the intercept-url tag use by default the java regex syntax.
b. Security rules may applied depending request parameter
524. A many-to-one association is the most common kind of association where an object can be associated with
multiple objects.
a)true
b)false
526. The bean in the xml file is important for specifying the view resolver and view components
a)true
b)false
528. Spring provides @Validator annotation and Binding Result class through which we can get the errors
raised by Validator implementation in the controller request handler method.
A)true
B)false
530.spring provides a comprehensive set of data binding-aware tags for handling form elements when
using JSP and spring web MVC
a)true
b)false
533.SessionFactory allows application to create hibernate session by reading hibernate configuration file
hibernate.cfg.xml
a)true
b)false
536. to create new xml configuration extension which of the following are relatively simple steps
a)all
b)coding one or more BeanDefinitionParser implementation
c)coding a custom NamespaceHandler implementation
d)authoring an XML schema to describe your custom elements
e)registering all artefacts with the spring
537. which of the following statements are view resolver pattern and works in spring MVC?
a)it is a J2EE pattern which allows a web application to dynamically choose a view technology
b) spring MVC framework supplies inbuilt view resolver for selecting view
c)view resolver holds mapping of different views ,controller return the name of the view which is
then passed to the view resolver for a appropriate view
d)its does not support HTML, JSP, Tapestry, JSF and other controller technologies