Week 8 Quiz Multiple Choice Flashcards
Given the following part of a configuration class, which line of code correctly retrieves the bean from the context?
@Bean(name=”myBeanName”)
public Student student(){
Return new Student();
}
Student student = (Student) context.getBean("myBeanName"); Student student = (Student) context.getBean("student"); Student student = context.getBean("Student"); Student student = (Student) context.getBean("mybeanname");
Student student = (Student) context.getBean(“myBeanName”);
Spring is
A dependency injection framework for JavaScript. A mocking library for Java. A JVM based programming language. A dependency injection framework for Java.
A dependency injection framework for Java.
A Spring bean is
The same as a Java bean. A class which is constructed and managed by Spring. Only classes defined in the Spring source code. Any bean annotated with @GetMapping.
A class which is constructed and managed by Spring.
The @Configuration annotation is used to
Provide XML configuration. Define a class as a configuration bean. Provide annotation driven configuration. Do the same as the @Autowired annotation.
Define a class as a configuration bean.
Which of the following is not a valid stereotype annotation?
@Component @Bean @Controller @Service
@Bean
In AOP, an aspect is
The modularization of a cross cutting concern. A location in code in which advice may be provided. A predicate expression used to match a join point. Implementation logic addressing cross cutting concerns.
A location in code in which advice may be provided.
In AOP, advice is
A location in code in which advice may be provided. The modularization of a cross cutting concern. Implementation logic addressing cross cutting concerns. A predicate expression used to match a join point.
A predicate expression used to match a join point.
Aspect oriented programming is a method of programming intended to address
Cross cutting concerns Aspects Isolated functionality Test driven development
Cross cutting concerns
The @RequestMapping annotation is used to
Provide a URL mapping to a resource for any HTTP method. Provide a URL mapping to a resource for only GET methods. Map a path variable to an array index. Provide data contained in a request body as a HashMap.
Provide a URL mapping to a resource for any HTTP method.
The @RequestBody annotation is used to
Define a class as a controller. Define that the return value of a method should be serialized to some form such as XML, JSON, ect. Define that the request body should be deserialized to a Java object from form such as XML, JSON, ect. Parse the a variable in the requested URL and injected to the method call as a parameter.
Define that the request body should be deserialized to a Java object from form such as XML, JSON, ect.
The @PathVariable annotation is used to
Define a class as a controller. Define that the return value of a method should be serialized to some form such as XML, JSON, ect. Define that the request body should be deserialized to a Java object from form such as XML, JSON, ect. Parse the a variable in the requested URL and injected to the method call as a parameter.
Parse the a variable in the requested URL and injected to the method call as a parameter.
When used on the class, the @RestController annotation implies what on all methods?
@ResponseBody @RequestBody @RequestMapping @RequestParam
@ResponseBody
The @Transactional annotation is used to
Define that the underlying code should be executed as a database transaction. Define that the underlying code is used to make a purchase. Define that the underlying code should never throw an exception. Does nothing.
Define that the underlying code should be executed as a database transaction.
Which of the following is not a way to get a bean from Spring?
Using the getBean method on the ApplicationContext or BeanFactory. Using @Autowire with a valid bean definition. Using an XML configuration with a valid bean reference. Using the @Aspect annotation before the declaration field, setter, or constructor.
Using an XML configuration with a valid bean reference.
Spring boot features an ‘opinionated configuration’ which means that:
It requires you to tell it how to configure all functionality. When not provided with configuration, it uses reasonable default configurations. It cannot be configured. You will never need to configure it.
When not provided with configuration, it uses reasonable default configurations.