Quiz
JGM - 5 - Test 2
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (46)
1Which of these can be used in Java-based or annotation-based Spring configuration? Select all that apply.
- A@Bean
- B@Configuration
- C@Scope
- D@Config
2Which of these is being described below? A bean instance in this scope lives within the lifetime of a single
HTTP Session- Aglobal session
- Brequest
- Csession
- Dapplication
3Which of these is true regarding Spring AOP CGLIB proxying?
- Afinal' methods cannot be advised.
- BIn addition to the springcore jar, the CGLIB jar is needed to be added on the classpath
- Cproxy-target-class="cglib" forces the use of CGLIB.
- DNone of the above.
4Which of these are called after all the bean's properties have been set (in other words, after dependency
injection is done)? Select all that apply.- AMethods annotated with @PostConstruct
- BafterPropertiesSet() as defined by the InitializingBean interface
- CA custom init method (i.e. specified in XML using the the 'init-method' attribute)
- Dthe class' constructor method
5Which of these attributes or annotations, enables the choice of registering a bean (or a set of beans) or not,
based on this attribute or annotation's value? Select all that apply.- A'profile' attribute of the XML 'beans' element
- B@Profile
- C@BeanProfile
- D@BeansProfile
6Which statements are true regarding AOP advices? Select all that apply.
- AThe proceed() on the ProceedingJoinPoint, in an @Around advice method, must be called up to 1 time
only. - B@AfterFinally advise is executed whether the advised method exits normally or not (throws
exception). - CThe first parameter of the @Around advice method must be of type ProceedingJoinPoint.
- DUsing @AfterThrowing with its property 'throwing', further filters the pointcut matching into those
methods that throw the exception type associated with the 'throwing' property.
- AThe proceed() on the ProceedingJoinPoint, in an @Around advice method, must be called up to 1 time
7Which of these statements are true regarding the DataAccessException exception class hierarchy? Select all
that apply.- AIts use helps convert proprietary checked exceptions, to a set of runtime exceptions.
- BIts use allows one to switch between persistence technologies fairly easily and it also allows one to
code without worrying about catching exceptions that are specific to each technology. - CDataAccessException instances thrown, wrap the original exception.
- DThe DataAccessException class is in the java.lang package.
8Fill in the blanks.
In Spring Security, upon successful ______, the ______ (which is most of the time a ______ object from the
UserDetailsService) is used to build the Authentication object that is stored in the SecurityContextHolder.
Select the one that applies best.- Aauthentication, authorization service, Principal
- Bauthorization, authorization service, UserDetails
- Cauthorization, authentication manager, Principal
- Dauthentication, principal, UserDetails
9which of these can be added after the code below to assist in the definition? Select all that apply.
DriverManagerDataSource myDataSource = new DriverManagerDataSource();- AmyDataSource.setDriverClass(.....);
- BmyDataSource.setConnectionUrl(.....);
- CmyDataSource.setUserId(.....);
- DmyDataSource.setPassword(.....);
10Which ones are true about the code below? Select all that apply.
<beans>
<import resources="myServices.xml"/>
<import resources="myResources/messageSourceA.xml"/>
<import resources="/myResources/messageSourceB.xml"/>
</beans>- ASpring will look for a file myServices.xml. The enclosing 'beans' element is not needed inside
myServices.xml. - BThe line with 'messageSourceB.xml' is malformed. There must not be a slash before 'myResources'.
- CThe attribute to be used is 'resource', not 'resources'.
- DIt is possible to reference files in parent directories using a relative path like "../".
- ASpring will look for a file myServices.xml. The enclosing 'beans' element is not needed inside
11Which of these are valid usage of the @RequestMapping annotation in Spring MVC? Select all that apply.
- A@RequestMapping(method = RequestMethod.PATCH)
- B@RequestMapping(value="/{systemId}", method = RequestMethod.HEAD)
- C@RequestMapping(value="/offline", method = RequestMethod.GET)
- D@RequestMapping("/")
12The 'Autowired' annotation can be applied to the following (select the one that applies best):
- Aconstructors
- Bconstructors and methods
- Cfields, setters and getters
- Dfields, constructors, methods
13Which of these classes assist in programmatic transaction demarcation and transaction exception handling?
It executes codes within a transaction using the TransactionCallback interface- ATransactionInterceptor
- BTransactionTemplate
- CTransactionStatus
- DPlatformTransactionManager
14The use of this makes it easier to mock and/or test java classes. Select the one that applies best.
- ASpring AOP
- Bjava interfaces
- Ctemplate design pattern
- DSpring Expression Language (SpEL)
15Which of these are true regarding Spring transactions? Select all that apply.
- AYou can call setRollbackOnly() on the TransactionStatus object to roll back the current transaction.
- BChecked exceptions, by default, in Spring declarative transactions, causes a roll back.
- CYou can omit the transaction-manager attribute in '<tx:advice/>' if the bean name of the transaction
manager that you want to wire in has the name 'txManager'. - DSpring Framework's declarative transaction support is enabled via AOP proxies.
16Fill in the 2 blanks.
________ can be extended to create a repository. Below is a way to activate it.
@Configuration
________ (basePackages="myPackage.myInstantRepos")
public class MyInstantRepoConfiguration {}- AJpaRepository, @EnableJpaRepositories
- BJpaTemplate, @EnableJpaRepositories
- CJpaTemplate, @EnableJpaRepository
- DJpaTemplate, @EnableSpringRepositories
17Which of these is the required communication protocol between client and service, in microservices systems?
Select the one that applies best.- AREST
- BXML Web Service
- CAsyncCloud
- DThere is no specific protocol required to do microservices although some use a preferred ideal one
18Which of these are things you can do in web.xml for Spring? Select all that apply.
- ADeclare the default ViewResolver
- BDeclare the root application context
- CDeclare a DispatcherServlet
- DDeclare the default MultipartResolver (for processing file uploads
19Which ones are true about Spring Framework's Test module? Select all that apply.
- AJUnit is supported.
- BIt provides consistent caching of contexts during test execution.
- CIt provides mock objects.
- DTestNG is not supported.
20Which of these will be qualified for the corresponding Autowired annotation definition below (where
'Weekend' is a custom qualifier)? Select all that apply.
@Autowired
@Weekend(timeOfDay="Morning")
private Greeter greeter;- A<qualifier value="Weekend.Morning"/>
- B<qualifier type="Weekend">
<attribute key="timeOfDay" value="Morning"/>
</qualifier> - C<meta key="timeOfDay" value="Morning"/>
- D<qualifier key="Weekend" value="Morning"/>
21Which ones are valid Autowired definitions? Select all that apply.
- A@Autowired
public void setMyInputs(Map<MyInput, String> myInputs) { - B@Autowired(required=true)
public MySource(MyConnection myConnection) { - C@Autowired
private MyFile[] myFiles; - D@Autowired(required=false, searchBy="type")
public void setMyInputs(Set<MyInput> myInputs) {...
- A@Autowired
22In which of these database system isolation levels can phantom reads occur? Select all that apply?
- ASerializable
- BRepeatable reads
- CRead uncommitted
- DRead committed
23Which one is the highest database system isolation level?
- ARead committed
- BRead uncommitted
- CRepeatable reads
- DSerializable
24Which one is true regarding the code below (where jdbcTemplate is a JdbcTemplate)?
this.jdbcTemplate.update("insert into Account (accountId, name) values (?, ?)",1, "John");- AIt will fail. "this.jdbcTemplate.insert" should be used instead of "this.jdbcTemplate.update".
- BIt is invalid. The update method requires a third parameter: an int[] which specifies the SQL types of
the arguments. - CThe code is valid. If the 'insert' command completes successfully, the code will return 1.
- DThe containing code for the mentioned code must handle (either catch or propagate) the
SQLException.
25In Spring MVC, which of these are a valid use of the @PathVariable? Select all that apply.
- A@RequestMapping(value="/users/{userId}")
public String viewUser(@PathVariable("users") String user, Model m) { - B@RequestMapping(value="/users/{userId}/addresses/{addressId}")
public String viewUserAddress(@PathVariable String userId, @PathVariable String addressId,
Model m) { - C@RequestMapping(value="/users/{userId}")
public String viewUser(@PathVariable("userId") String personnelId, Model m) { - D@RequestMapping(value="/users/{userId}")
public String viewUser(@PathVariable String userId, Model m) {
- A@RequestMapping(value="/users/{userId}")
26Fill in the blanks. ________ can be annotated on a property whose type is ________. An implementation of
________ can create an ________ and use it to perform database operations. Select the one that applies best.- A@PersistenceContext, EntityFactory, EntityFactory, Entity
- B@Entity, EntityManagerFactory, EntityManagerFactory, EntityManager
- C@PersistenceUnit, EntityManagerFactory, EntityManagerFactory, EntityManager
- D@PersistenceContext, EntityManagerFactory, EntityManagerFactory, EntityManager
27Which of these is described below? Select the one that applies best.
It enables the modularization of concerns that cut across multiple types and objects.- AModel-View-Controller (MVC)
- BObject-Oriented Programming (OOP)
- CAspect-Oriented Programming (AOP)
- DSpring Framework
28Fill in the blanks. Select the one that applies best.
______ (in a class annotated with ______) enables MVC Java config.- A@EnableMVC, @Configuration
- B@EnableMVC, @WebConfiguration
- C@EnableWebMVC, @WebConfiguration
- D@EnableWebMVC, @Configuration
29Which of these are considered idempotent REST operations? Select all that apply.
- APOST
- BPUT
- CGET
- DDELETE
30This activity is the linking of aspects with other application types or objects to create an advised object. Spring
AOP performs this at runtime. Select the one that applies best.- ADependency Injection
- BSpring configuration validation
- CAutowiring
- DWeaving
31Which of these is true when working with the following: SpringJUnit4ClassRunner, @Test and @Transactional?
- AThe default rollback policy is: false.
- B@Default can set the class' default rollback policy.
- CThe TestContext framework can be instructed to cause the transaction to commit instead of roll back via the @Commit annotation.
- DAll of the above.
32Which ones are true about the 3 destruction customization ways? (The 3 ways are: methods annotated with
@PreDestroy, destroy() in the DisposableBean interface, destroy-method method in XML-based
configuration.) Select all that apply.- AWhen all 3 are used and they use different method names, the order of execution is: Methods
annotated with @PreDestroy, destroy() in the DisposableBean interface, destroy-method method - BIf 2 destruction customization ways are used, and the method name is the same, that method is
executed once only. - CIf 2 destruction customization ways are used, and the method name is the same, that method is
executed 2 times.
- AWhen all 3 are used and they use different method names, the order of execution is: Methods
33To which is the code below equivalent to?
@Configuration
public class AcmeConfig {
@Bean
public com.foo.AcmeService acmeService() {
return new com.foo.AcmeServiceImpl();
}
}- A<beans>
<bean id="acmeConfig" class="com.foo.AcmeService"/>
</beans> - B<beans>
<bean id="acmeService" class="com.foo.AcmeServiceImpl"/>
</beans> - C<beans>
<bean id="acmeConfig" class="com.foo.AcmeServiceImpl"/>
</beans> - DNone of the above. The code will not run as intended. The @Bean requires a 'name' attribute.
- A<beans>
34Which of these are true regarding Spring Security's web infrastructure? Select all that apply.
- AIt is based entirely on standard servlet filters.
- BSpring Security uses a chain of filters internally, each of which has a particular purpose.
- CIt deals in HttpServletRequest and HttpServletResponse.
- DRequests can come from a browser, a web service client, an HttpInvoker or an AJAX application.
35Which of these is being described below? Select the one that applies best.
It is the property placeholder syntax. It can only be used to de-reference properties.- A#{...}
- B@Property(...)
- C${...}
- D@PropertyRef(...)
36Fill in the blank. In Spring MVC, some of the values returned by _____________ are: a String, a View, or a ModelAndView.
- AView Resolvers methods
- BHandlerMapping methods
- CController handler methods
- DModel methods
37Which of these can be used by Spring Boot to externalize configuration? Select all that apply.
- Aproperties files
- BYAML files
- Cenvironment variables
- DXML files
38Which of these is true about AOP and Spring AOP?
- AAOP helps unrelated codes be kept outside of the advised classes.
- BAOP helps code be written once, reused, and not duplicated in many places.
- CSpring AOP can be configured in two ways: by XML and by annotations.
- DAll of the above
39Which of these are true about security and Spring Security? Select all that apply.
- ASecurity is a cross-cutting concern.
- BSpring secures method invocations using Spring AOP.
- CSpring secures web requests using Spring AOP.
40In XML-based configuration, what is the 'init-method' attribute of the 'bean' XML element for?
- AWhen there is vagueness in the autowiring of constructors, init-method is used to specify which
constructor to use. - BIt is used to specify if a bean is a Spring singleton or not.
- CJust like the InitializingBean interface, it allows a bean to perform initialization tasks after all needed
properties on the bean have been set by the container. - DThere is no such attribute.
- AWhen there is vagueness in the autowiring of constructors, init-method is used to specify which
41Eureka, Archaius, Ribbon and Hystrix, are some of the projects this company is involved in, and uses them in
working with microservices- AAdobe
- BNetflix
- CUber
- DSnapchat
42Which of these are true about working with REST in Spring? Select all that apply.
- A@RestController is used on the client side, not the server side.
- BRestTemplate is used on the server side, not the client side.
- CSpring MVC binaries are needed in the classpath.
- DREST usually uses the Rest protocol, instead of the HTTP protocol.
43Which of these is true regarding the code below?
@Transactional (propagation = Propagation.REQUIRES_NEW)
public class MyClass {
public void method1() {.....}
public void method2() {.....}
}- AIt is the same as annotating both methods with below.
@Transactional (propagation = Propagation.REQUIRES_NEW) - BIf a client code (e.g. class MyClient) calls method1(), and method1() calls method2(), method2() will
run under a new transaction, not the one that method1() is running on. - CIt is invalid. @Transactional can be applied on methods only.
- DNone of the above.
- AIt is the same as annotating both methods with below.
44Which of these is supported as an embedded container in Spring Boot? Select all that apply.
- ATomcat
- BJetty
- CUndertow
- DAzure
45Which ones are true about Spring bean property values, when using XML-based configuration? Select all that
apply.- ASpring converts values to the appropriate type prior to being added to a strongly-typed Collection. This is done using the 'typed' attribute.
- BSpring's support on strongly-type Collections type-conversion is done by Spring using reflection.
- CSpring treats empty arguments for properties and the like as null.
- D<null/> represents and is treated as an empty string.
46Which of these advices, when used, will have a chance to execute some code before the join point is executed?
Select all that apply- A@AfterReturning
- B@Before
- C@Around
- D@After
Information
- Description
- Quiz on JGM - 5 - Test 2, created by Jorge Garrido on 19/03/2018.
- Author
- Jorge Garrido
- Language
- Español
- Views
- 1
- Tags
- Rating
- No ratings yet Rate this quiz