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.
Using the default configuration, Spring boot includes an embedded ________.
tomcat server postgres server in memory database user
tomcat server
What is Spring MVC?
A fully featured MVC framework that is a module of Spring. A module that provides for integration with Struts. Required for DI (Dependency Injection). Allows for component scanning through the component-scan tag in the applicationContext.xml.
A fully featured MVC framework that is a module of Spring.
What types of Dependency injection does spring supports?
Constructor based, Setter based Constructor based, Setter based, Getter Based Setter based, Getter based, Properties based Constructor based, Setter based, Properties based
Constructor based, Setter based
Explanation : Spring supports Constructor based, Setter based injections.
What is the current core container in Spring?
BeanFactory ApplicationContext WebContext XMLBeanFactory
ApplicationContext
Which of these is NOT a benefit of using Spring?
Your code is more decoupled Your code is more easily testable Cross-cutting concerns can be removed from application logic Testing your code isn't needed - the Spring container cannot inject a bean with bad data
Testing your code isn’t needed - the Spring container cannot inject a bean with bad data
The Spring Web MVC framework is designed around a _____ that handles all the HTTP requests and responses
HandlerMapping ViewResolver DispatcherServlet Controller
DispatcherServlet
This annotation registers the class as a controller and must be used in conjunction with tag in the XML to automatically discover and register the controllers as Spring beans.
@Controller @Handler @RequestMapping @Path
@Controller
What is Bean Factory?
A means for resolving text messages, including support for internationalization A class you define and create in your Spring application that implements the Factory design pattern Holds Bean Definitions of multiple beans within itself and then instantiates the bean when requested A Web GUI tool that allows you to access your bean definitions
Holds Bean Definitions of multiple beans within itself and then instantiates the bean when requested
Spring MVC uses which design pattern?
DAO Business Delegates Front Controller Flyweight
Front Controller