Week 8 Quiz Multiple Choice Flashcards

1
Q

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");
A

Student student = (Student) context.getBean(“myBeanName”);

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

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

A dependency injection framework for Java.

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

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

A class which is constructed and managed by Spring.

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

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.
A

Define a class as a configuration bean.

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 stereotype annotation?

@Component

@Bean

@Controller

@Service
A

@Bean

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

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

A location in code in which advice may be provided.

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

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

A predicate expression used to match a join point.

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

Aspect oriented programming is a method of programming intended to address

Cross cutting concerns

Aspects

Isolated functionality

Test driven development
A

Cross cutting concerns

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

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.
A

Provide a URL mapping to a resource for any HTTP method.

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

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.
A

Define that the request body should be deserialized to a Java object from form such as XML, JSON, ect.

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

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.
A

Parse the a variable in the requested URL and injected to the method call as a parameter.

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

When used on the class, the @RestController annotation implies what on all methods?

@ResponseBody

@RequestBody

@RequestMapping

@RequestParam
A

@ResponseBody

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

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.
A

Define that the underlying code should be executed as a database transaction.

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

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.
A

Using an XML configuration with a valid bean reference.

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

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.
A

When not provided with configuration, it uses reasonable default configurations.

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

Using the default configuration, Spring boot includes an embedded ________.

tomcat server

postgres server

in memory database

user
A

tomcat server

17
Q

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

A fully featured MVC framework that is a module of Spring.

18
Q

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
A

Constructor based, Setter based

Explanation : Spring supports Constructor based, Setter based injections.
19
Q

What is the current core container in Spring?

BeanFactory

ApplicationContext

WebContext

XMLBeanFactory
A

ApplicationContext

20
Q

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
A

Testing your code isn’t needed - the Spring container cannot inject a bean with bad data

21
Q

The Spring Web MVC framework is designed around a _____ that handles all the HTTP requests and responses

HandlerMapping

ViewResolver

DispatcherServlet

Controller
A

DispatcherServlet

22
Q

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
A

@Controller

23
Q

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
A

Holds Bean Definitions of multiple beans within itself and then instantiates the bean when requested

24
Q

Spring MVC uses which design pattern?

DAO

Business Delegates

Front Controller

Flyweight
A

Front Controller

25
Q

_____ advice executes if a method exits by throwing an exception.

Before

After

After returning

After throwing

Around
A

After throwing

26
Q

_____ advice surrounds a join point such as a method invocation. This is the most powerful kind of advice.

Before

After
 
After returning

After throwing
 
Around
A

Around

27
Q

_____ advice executes regardless of the means by which a join point exits (normal or exceptional return).

Before
 
After
 
After returning
 
After throwing
 
 Around
A

After returning

28
Q

____ advice executes before a join point, but does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).

Before

After

After returning

After throwing

Around
A

Before

29
Q

Which of the following is not a valid HTTP method used in REST

OPTIONS

DELETE

DATE

POST
A

DATE

Explanation : DATE is not a HTTP Verb and is not a valid HTTP methods used in RESTful web services.

30
Q

What is a resource in REST?

Any content accessible through the Web Service

A socket connection to access the Web Service

A database connection object for the service to access its data

All of the above
A

Any content accessible through the Web Service

31
Q

What message protocol is used in REST?

SMTP

HTTP

FTP

All of the above
A

HTTP

32
Q

What does REST stand for?

Representational State Transfer

Representational Structured Transfer

Representational System Transfer

Representational State Translation
A

Representational State Transfer

33
Q

How are exceptions handled in REST?

A web service should pass back an Exception object to the client

A web service should use HTTP error codes like 403 to show access forbidden using the Response object

Using faults like the way SOAP does

Exceptions should not be sent back to the client
A

A web service should use HTTP error codes like 403 to show access forbidden using the Response object

34
Q

REST - statelessness
RESTful APIs should be:

Stateless

Stateful
A

Stateless

35
Q

What is contained in an HTTP Request?
Select all that apply from the following:

Headers containing metadata

A verb

A body, potentially containing data

A destination URL

A response

An HTML form

A

Headers containing metadata,
A body, potentially containing data,
A destination URL

36
Q

Which of the following HTTP Status code means INTERNAL SERVER ERROR, states that server has thrown some exception while executing the method?

500

401

404

409
A

500
Explanation : HTTP Status Code 500 means INTERNAL SERVER ERROR, states that server has thrown some exception while executing the method.

37
Q

Which is not one of the core components of an HTTP response?

Response Header

Response Body

HTTP Version

Status Code

URI
A

URI