Spring Programming Flashcards

1
Q

Do you need to define any dependencies in order to use beans from one extension in the other extension?
If yes, where?

  • There is no need to define any dependencies
  • All beans can be accessed with or without defining dependencies
  • Extensioninfo.xml
  • Localextensions.xml
A
  • Extensioninfo.xml
  • Localextensions.xml
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default bean scope if bean scope is not defined?

  • session
  • request
  • tenant
  • singleton
A

singleton

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How the GenericApplicationContext is constructed and when is it loaded?

  • Is constructed using all configuration files of all the extensions by start-up time and is loaded during hybris startup
  • Is constructed using configuration files of the platform core extensions by start-up time and is loaded when you run a hybris build
  • Is constructed using all configuration files of all the extensions by start-up time and is loaded when you run a hybris build
  • Is constructed using configuration files of the platform core extensions by start-up time and is loaded during hybris startup
A

Is constructed using all configuration files of all the extensions by start-up time and is loaded during hybris startup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following listeners will allow beans defined within Web Application Context to refer the beans available in Global Application context?

  • org.springframework.wecontext.ContextLoaderListener
  • org.springframework.wecontext.request.RequestContextListener
  • de.hybris.platform.spring.HybrisContextLoaderListener
  • none of the above
A

de.hybris.platform.spring.HybrisContextLoaderListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which of the following is not a valid type of Advice?

  • Around advice
  • After advice
  • After throwing advice
  • Before throwing advice
A

Before throwing advice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following are common and important Application Context implementations?

  • ClassPathXmlApplicationContext
  • FileSystemXmlApplicationContext
  • XmlWebApplicationContext
  • HybrisApplicationContext
A

ClassPathXmlApplicationContext

FileSystemXmlApplicationContext

XmlWebApplicationContext

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following are two important bean lifecycle methods?

  • setup and teardown
  • init and destroy
  • create and destroy
  • setup and destroy
A

setup and teardown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following bean scopes are valid only in the context of a web-aware Spring ApplicationContext?

  • tenant
  • prototype
  • yrequest
  • request
A

request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which of the following variable resolver lets you use Spring with JSF?

  • org.springframework.wejsf.DelegatingVariableResolver
  • org.springframework.weDelegatingVariableResolver
  • Spring cannot be used with JSF
  • none of the above
A

org.springframework.wejsf.DelegatingVariableResolver

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following Spring Security concepts are relevant to Hybris?

  • Authentication Provider
  • Access Decision Voter
  • Password Callback
  • All of the above
A

All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Choose which is true:

  • Central to the Spring Framework is its IOC container
  • IOC provides a consistent means of configuring and managing Java objects using call-backs.
  • IOC container is responsible for managing object lifecycles
  • The object life cycle used for creates objects, call initialization methods, and configure objects by wiring them together.
  • All of above
  • None
A

All of above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the Type of Proxy in Spring Framework?

  • Static
  • Dynamic
  • Response
  • None
A

Dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How could you externalize constants from a Spring configuration file or a Spring annotation into a .properties file ? Select one or more answers

  • By using the <constant></constant> tag
  • By declaring the ConstantPlaceholderConfigurer bean post processor
  • By using the <property-placeholder></property-placeholder> tag
  • By using the c: namespace
A

By using the <property-placeholder></property-placeholder> tag

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What statements are not correct? Select a unique answer.

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

All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What could not return a Spring MVC controller? Select a single answer.

  • An absolute path to the view
  • A logical view name
  • A new JstlView
  • void
A

An absolute path to the view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where do you cannot declare Spring MVC controller? Select one or more answers.

  • In a Spring application context XML configuration file
  • Into the wexml file of the web application
  • Into the java code by using annotations
  • Into the JSP pages
A
  • Into the wexml file of the web application
  • Into the JSP pages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How could you secure MVC controller with Spring Security? Select a unique answer.

  • With the @Secured annotation
  • With the @RolesAllowed annotation
  • In a XML security configuration file
  • All of the above
  • None of the above
A

All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are the possible mechanisms provided by Spring Security to store user details? Select one or more correct answers.

  • Database
  • JAAS
  • LDAP
  • Properties file
A
  • Database
  • JAAS
  • LDAP
  • Properties file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is true about Spring security configuration and the security namespace? Select one or more correct answers

  • The access attribute of the intercept-url tag support both EL and constants together.
  • The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is the first that matches
  • The patterns declared into the intercept-url tag use by default the java regex syntax.
  • Security rules may applied depending request parameter
A

The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is the first that matches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Spring MVC is a request-based framework.

  • Yes
  • No
A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Spring’s Transaction management feature can fully replace all the features of EJB’s Container managed transaction

  • Yes except the global transactions
  • FALSE
  • True , no exceptions
A

Yes except the global transactions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What do you understand by Inversion of Control(IO

  • The object define their dependencies and the container injects the dependencies when it creates the bean
  • A property available in the Spring Framework in which caller methods control the creation of parent
  • Inversion of Control (Io is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time using static analysis
A
  • The object define their dependencies and the container injects the dependencies when it creates the bean
  • Inversion of Control (Io is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time using static analysis
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are the types of injection supported by Spring ?

Constructor Injection only

Constructor Injection and Setter Injection

Constructor Injection , Setter Injection and Interface Injection

A

Constructor Injection and Setter Injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Can you instantiate a static inner class in spring

No. Static classes are not supported

Yes. They are instantiated by default with the class

Yes. But you will have to use the binary name of the class

A

Yes. But you will have to use the binary name of the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Which of the following features are available when using the spring templating class such as JdbcTemplate * Automatic Transaction Management * Exception Handling * Load Balancing * Cache Management * Resource look up
* Automatic Transaction Management * Exception Handling * Resource look up
26
The basic principle behind Dependency Injection(DI) is that the objects define their dependencies . What are the different ways in which an object can define its dependency * Through Constructor arguments * Arguments to a factory method * Properties which are set on the object instance after it has been constructed or returned from a factory method * xml file
* Through Constructor arguments * Arguments to a factory method * Properties which are set on the object instance after it has been constructed or returned from a factory method
27
What are important ApplicationContext implementations in spring framework XmlWebApplicationContext FileSystemXmlApplicationContext ClassPathXmlApplicationContext URLPathXmlApplicationContext
28
What is technically a 'bean' in Spring It is a special component of the IOC container It is the regular java bean with some special features and capabilities in spring A bean is simply an object that is instantiated, assembled and otherwise managed by a Spring IoC container; other than that, there is nothing special about a bean
29
I want to add the MessageSource functionality to application, providing access to messages in i18n-style. Which one should I use ApplicationContext Properties file ServletContext
30
An application server is required for Spring's Transaction mechanism to run. This statement is True/false TRUE FALSE
31
What is true about Spring security configuration and the security namespace? Select one or more correct answers The access attribute of the intercept-url tag support both EL and constants together. null The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is the first that matches. null The patterns declared into the intercept-url tag use by default the java regex syntax. Security rules may applied depending request parameter. Explanation-- Security rules may apply to request URL, request method (GET, POST ) but not to request parameters.
32
What is the easiest method to write a unit test void displayAccount(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException void displayAccount(HttpServletRequest req, HttpSession Session) throws ServletException, IOException @RequestMapping("/displayAccount")String displayAccount(@RequestParam("accountId") int id, Model model). @RequestMapping("/displayAccount")String displayAccount(@PathVariable("accountId") int id, Model model).
33
Which of the following are true Registry.getApplicationContext() always returns the GlobalApplicationContext Dispatcher servlet is configured in the web.xml file. Yrequest scope is similar to the standard spring request scope and is used within the web application context. Tenant scope makes sure that one instance of bean is shared by all the tenants
34
The configuration of a web ApplicationContext is done in Extension-spring.xml Extension-web-spring.xml Web.xml Project.properties file
35
The WebApplicationContext is created from configuration files specified -------------- parameter contextConfigLocation webContextLocation contextLoaderListener servletConfigLocation
36
Which of the following are true Spring supports injection through getters and setters Spring supports constructor injection Spring supports interface injection Spring doesn’t support constructor injection
37
If we need to specify a configuration file for dispatcher Servlet, which of the following needs to be done tag inside the tag. \< servlet\> tag inside the \< init-param\> tag. Any of these None of these
38
entry is made in …………………….. Project.properties extensioninfo.xml Wexml {Extension\_name}.spring.xml
39
Which of the following are true The tenant scope registered at the global ApplicationContext is not inherited by child ApplicationContext The tenant scope registered at the global ApplicationContext is inherited by child ApplicationContext If you need to use the tenant scope in your web ApplicationContext, you have to register it separately by specifying the fully qualified class name de.hybris.platform.spring.TenantScope: There is no need to register a tenant scope for using it in the web application context.
40
When we redefine a global bean in the web application context The global bean is modified and overridden No real overriding is done, instead a second definition is created at the web ApplicationContext. The redefined bean overlays the Global bean. None of these
41
Which of the following are benefits of Inversion Of Control IOC containers make unit testing and switching implementations very easy. Minimizes the amount of code in your application IOC containers support eager instantiation and lazy loading of services IOC Containers make the application more testable by requiring JNDI lookup mechanism
42
Which of the below are true about Application context The application context implements MessageSource Application contexts can publish events to beans that are registered as listeners. It doesn’t support i18n of text messages . Application contexts provide a generic way to load file resources
43
Which messageResource used in spring? ResourceBundleMessageSource StaticMessageSource both none
44
Which of the following is Marker Interface in Spring AOP? MethodInterceptor ThrowsAdvice Both None
45
Which of the following is Dynamic point-cut class in Spring AOP ControlFlowPointcut NameMatchMethodPointcut RegexpMethodPointcut None
46
Which of the following is not type of Autowire By name By Type Constructor auto detect setter
47
What data access technology is supported by the Spring framework? Select one or more answers JDBC NoSQL Hibernate JPA
48
Which module present in Spring web layer Web-Servlet module Web-Struts module Web-portal module All above
49
"51 Using JdbcTemplate, what is the spring provided class you will use for result set parsing and merging rows into a single object? Select a unique answer RowMapper RowCallbackHandler ResultSetExtractor ResultSetMapper"
50
"52 What is the default rollback policy in transaction management? Rollback for any Exception Rollback for RuntimeException Rollback for checked exceptions Always commit"
51
"53 What are the features of the XML context namespace? Select one or many answers @Transactional annotation scanning @Aspect annotation detection Enabling @Autowired annotation enabling @Component annotation scanning"
52
"54 How could you secure MVC controller with Spring Security? Select a unique answer With the @Secured annotation With the @RolesAllowed annotation In a XML security configuration file All of the above None of the above"
53
``` "55 Select one or many correct answers about spring bean life cycle The method annoted with @PostConstruct is called after bean instantiation and before properties setting of the bean The method @PreDestroy of a prototype bean is called when the bean is garbage collected The init() method declared in the init -method attribute of a bean is called before the afterPropertiesSet callback method of the InitializingBean interface The method annoted with @PostConstruct is called before the afterPropertiesSet callback method of the InitializingBean interface" ```
54
"56 Which of the following are true: During startup, the hybris Multichannel Suite creates one global GenericApplicationContext, which contains all beans defined at the Core Module of all extensions. GenericApplicationContext is an implementation of the ApplicationContext interface. The GenericApplicationContext is constructed using all configuration files of the extensions by start-up time. you can access the beans of other extensions at your configuration file or override other extension's beans definitions."
55
"57 For adding bean definitions to the global ApplicationContext make sure that a _______________ file exists in the resources directory of your extension a -spring.xml
b    -web-spring.xml
c    -items.xml
Both a and b are correct"
56
"58 If you want to use more than one configuration file, you can configure the list of configuration files in the ________________ file using a comma separated list of files. extension's project.properties extension's platformhome.properties extension's oscache.properties All the above"
57
"59 Which of the following are true: The core-spring.xml file of the core extension adds a special scope named tenant to the global ApplicationContext The tenant scope makes sure that the bean is instantiated individually for each individual tenant of the hybris. If you reference tenant-specific classes like services or DAOs inside your implementation, you have to use the tenant scope instead of the default Spring singleton scope. If you need to use the tenant scope in your web ApplicationContext, you have to register it separately by specifying the fully qualified class name de.hybris.platform.spring.TenantScope."
58
"60 Which of these are true regarding annotation-based container configuration. allows various annotations to be detected XML injection is performed before annotation injection. If a configuration exists in both XML and annotation, the annotation configuration is used Instead of using , you can choose to define the individual BeanPostProcessors for the concerned annotations explicitly." "61 If you have to assure that the configuration of your extension will be loaded later than that of another extension, just add a entry to the __________________ file of your extension
extensioninfo.xml 
-spring.xml
buildcallbacks.xml
wexml"
59
"62 The _____________ file of the core extension adds a special scope named tenant to the global ApplicationContext core-spring.xml -spring.xml
-web-spring.xml
-items.xml"
60
"63 How could you secure MVC controller with Spring Security? With the @RolesAllowed annotation With the @Secured annotation All of the above None of the above"
61
"64 The hybris Multichannel Suite provides a ___________ for setting the global ApplicationContext automatically as parent of your web ApplicationContext. HybrisContextLoaderListener RequestContextListener All of the above None of the above"
62
"65 Which of the following are true: the configuration of a DispatcherServlet implicates a new application context different to the root web application context If you want to specify a configuration file for the DispatcherContext you have to use the tag inside the tag.
For each servlet configuration using a derive of the DispatcherServlet, an own application context is created, whereas the root web application context is set as parent.
if you have configured your root web application context using
the HybrisContextLoaderListener you are also able to access beans of the global ApplicationContext"
63
"66 Which of the following are correct Spring container/configuration xmls can be integrated with web application through wexml. In default behavior Spring instantiates singleton beans at the time of startup, which is called eagerly instantiation. By Autowiring, Spring injects dependencies without having to specify those explicitly. Default scope of spring is prototype"
64
"67 What are the implementations of Application Context? ClassPathXmlApplicationContext ClassPathXmlWebApplicationContext FileSystemXmlApplicationContext XmlWebApplicationContext "
65
"68 In the Spring ApplicationContext, hybris services are of tenant scope, not singleton. TRUE FALSE None"
66
"69 How to ensure your configuration loads later than other extensions? Change the order of extensions in ant script The order of build is determined by hybris Add entry in extensioninfo.xml
None of the above"
67
"70 The tenant scope has the following features Applicable in global ApplicationContext only Instantiates bean individually for each individual tenant of the hybris Creates one instance of bean for all tenents to use It is not inherited by the child ApplicationContext"
68
"71 How can you configure the global ApplicationContext as parent of extension's web ApplicationContext Providing dependency Using HybrisContextLoaderListener Injecting context loader in the wexml None of above"
69
"72 What is the use of RequestContextListener Enable the usage of request and session scopes Enable the usage of global web application context Enable security in the web extensions none of above"
70
"73 What is the Core of Spring MVC? WebServlet DispatchController DispacherServlet RequestDispacher"
71
"74 In what order will request pass through the spring security? a Filter security interceptor b Exception translation filter c Integration filter d Authentication processing filter Specify the correct order of the request flow : a, d, c, b a, d, b, c c, d, b, a a, b, c, d"
72
"75 What are the ways in which message is published to a channed within hybris? Messaging gateways Http request Messaging Channel UDP "
73
"76 What are different types of DI supported by spring? Constructor Injection Setter Injection Class Injection Interface Injection"
74
"77 What are the advantages of using spring It reduces coupling in code and improves maintainability. It does not have enterprise services capabality Heavy weight replacement for Application server Dependency Injection can be used to improve testability."
75
"78 What are the bean scopes in spring? singleton, public, request, session, global private, prototype, request, session, global singleton, prototype, request, session, global singleton, prototype, request, session, tenant "
76
"79 Which of the following are true In the Spring ApplicationContext, hybris services are of tenant scope, not singleton. During startup, the hybris Multichannel Suite creates one global GenericApplicationContext, which contains all beans defined at the Core Module of all extensions GenericApplicationContext is an implementation of the BeanFactory Beans of other extensions may be overridden/accessed at your configuration file "
77
"80 Which method may be used to access the current servletContext? getApplicationContext() getGlobalApplicationContext() getContext() getServletContext()"
78
"81 The yrequest scope has the following features Applicable in global ApplicationContext only Similar to request scope of spring outside of web application context Bind's beans to the application context for a single request. Garbage collected once the session is deactivated"
79
"82 How can you pass the configuration file for Dispach servler?


none of above"
80
"83 How to configure Anonymous login? By configuring the
Customisation of the username and authority is possible in the
Configuring the  
None of the above"
81
"84 What is the use of LoginToken? Type that Contains the login credentials Session attribute holds the user data A persistent cookie containing the Authentication data beyond HTTP Session None of the above"
82
"85 What are the decision managers in spring security? AffirmativeBased ConsensusBased UnanimousBased None of the above"
83
"86 What are the static methods provided by hybris Multichannel Suite to get the current ApplicationContext at Registry getApplicationContext() getLocalApplicationContext() getGlobalApplicationContext() None of the above"
84
"87 Which of these are true regarding annotation-based container configuration allows various annotations to be detecte XML injection is performed before annotation injection. If a configuration exists in both XML and annotation, the annotation configuration is use Instead of using , you can choose to define the individual BeanPostProcessors for the concerned annotations explicitly"
85
"88 What are the different points where weaving can be applied Compile Time Classload Time Runtime None of the above"
86
"89 What are the different types of bean injections getter injection setter injection constructor injection None of the above"
87
"90 How many types of Autowiring can be done One Two Three Four"
88
"91 What are the different advice types in Spring Before, After Around, Over Around, Throws Both 2 and 3 are correct Only 1 is corret Both 1 and 3 are correct Both 1 and 2 are correct"
89
"92 What are the features of Spring Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects. The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling Spring framework provides a generic abstraction layer for transaction management Spring framework is light weight and non transparency."
90
"93 Which of the following is true Spring AOP was not used in the Hybris Multichannel suite Spring AOP is used in the Hybris Multichannel suite Spring AOP can never be used in the Hybris Multichannel suite None of the above"
91
"94 What are the common implementations of the Application Context ClassPathXmlApplicationContext FileSystemXmlApplicationContext XmlWebApplicationContext None of the above"
92
"95 Tenant scope in Hybris is the wrapper of \_\_\_\_\_\_\_\_\_\_\_ request scope singleton Scope session scope prototype scope"
93
"96 Which of the following dependency injection is not supported by the spring framework Setter Injection Constructor Injection Interface Injection None."
94
"98 Which attribute can use for injects collaborate objects to dependent object in spring framework

Both
none "
95
"99 What would happen if we have a prototype bean injected into a singleton bean It will return the same instance of the prototype It will return the different instance of the prototype Both None "
96
"100 A bean can be marked abstract by abstract=true, does not that mean we have to make the corresponding java class abstract Yes No Confused Does not matter"