CCP - 1 Spring
CCP - 1 Spring
4) Can you inject null and empty string values in Spring? ----- yes
7)Following class can be extended to create custom event in spring. ans: ApplicationEvent
10) How many instances can be created for a global session ---- one
11) What display the data with help of model? ----- View
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>
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
A - DB2/NT
B - MySQL
C - FoundationDB
D - PostgreSQL
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
Select One
a. Both I and II are correct
b. II only
c. I only
d. Both I and II are incorrect
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
A.FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,
WebXmlApplicationContext
B.FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext
C.AdvancedApplicationContext, FileApplicationContext
D.FileSystemApplicationContext, ClassPathApplicationContext
35) The central artifact in spring javConfig is the @Configuration annotated class?-----True
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
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
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
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
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
55) Form tags are available in springs is more compatible with html tags for better development.-------True
59) Index and type can be used in the constrictor-arg at the same time? -------True
a) <many-to-many>
b) <many-to-one>
c) None of the list
d) <one-to-many>
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
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
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?
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
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
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
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
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?
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)
80) Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>
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
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.
controller
dispatcher servlet
model
browser
Which of the following handles all the HTTP requests and response?
Ans: Dispatcher Servlet
93) Application contexts can publish events to beans that are registered as listeners.--------true
One-to-One Association
Many-to-One Association
One-to-Many Association
Many-to-Many Association
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
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
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
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
15. Spring MVC provides a JSP tag library(Spring form) for making it easier to bind form elements to
model data.-------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
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
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
TRUE
FALSE
TRUE
FALSE
ContextStartedEvent
. ContextRefreshedEvent
ContextInitializedEvent
ContextReadyEvent
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
38. How the Spring DispatcherServlet supports for returning the last-modification-date, as specified by the
Servlet API ?
39. WebApplicationContext has more scopes like request, session, globalSession to the standard
Application context (which only provides Singleton and Prototype scopes)-----------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
classpath:
file:
http:
https:
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.
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
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
queryForInt(args)
queryForList(args)
getJdbcOperations()
getNamedParameterJdbsOperations()
are all present in which of the following class?
SimpleJdbcTemplate
JdbcTemplate
NamedParameterJdbcTemplate
None of the above
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/>
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
@PreConstruct
@PreDestroy
@Resource
@PostConstruct
@Autowired
@Controller
62. In Spring's form tag library which of the following tags are valid?
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
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){
}
}
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.