With the reactive programming model in Spring Boot, Reactive Data Repositories allow for _____ database interaction.

  • Asynchronous
  • Blocking
  • Sequential
  • Synchronous
With the reactive programming model in Spring Boot, "Reactive Data Repositories" allow for "asynchronous" database interaction. Reactive Data Repositories, part of Spring Data's reactive support, enable non-blocking database access by providing a reactive API for interacting with databases. This allows applications to efficiently work with data streams and handle concurrent requests without blocking threads.

In Spring Boot, a custom error response can be returned from an exception handler by returning an instance of _____.

  • Exception
  • Model
  • ModelAndView
  • ResponseEntity
In Spring Boot, when you want to return a custom error response from an exception handler, you can do so by returning an instance of ResponseEntity. This allows you to customize the HTTP status code, headers, and response body to provide detailed error information.

The _____ in Spring Security can be used to execute some logic when a user logs in successfully.

  • AuthenticationFailureHandler
  • AuthenticationSuccessHandler
  • SecurityConfigurerAdapter
  • UserDetails
In Spring Security, the AuthenticationSuccessHandler interface can be used to execute custom logic when a user logs in successfully. This is useful for tasks like logging successful login attempts or redirecting users to specific pages after login. The AuthenticationSuccessHandler interface provides flexibility for handling successful authentication events.

The _____ annotation in Spring Data JPA can be used to eagerly fetch the associated entities from the database.

  • @EagerFetch
  • @Fetch
  • @FetchType.EAGER
  • @Fetch.EAGER
The @FetchType.EAGER annotation in Spring Data JPA can be used to eagerly fetch the associated entities from the database. When an entity is loaded, all its associations marked with FetchType.EAGER are fetched immediately along with the main entity, reducing the number of database queries. However, you should use this option judiciously as it can lead to performance issues if overused.

Which annotation is predominantly used in Spring Boot to write a JUnit test for a class?

  • @Autowired
  • @RunWith
  • @SpringBootTest
  • @Test
In Spring Boot, the @Test annotation is predominantly used to indicate that a method is a JUnit test method. It marks the method as a test to be run by the JUnit framework.

In JUnit, _____ tests allow you to run the same test multiple times with different arguments.

  • Iterative
  • Loop
  • MultiTest
  • Parameterized
In JUnit, Parameterized tests allow you to run the same test method multiple times with different sets of input arguments. This is useful for testing the same logic with various input values and ensuring that it behaves correctly for all cases.

How would you use Mockito to simulate the throwing of an exception by a method?

  • Use doThrow(Exception.class).when(mockedObject).methodCall()
  • Use expect(exception).when(mockedObject).methodCall()
  • Use mockedObject.throwException(Exception.class)
  • Use when(methodCall).thenThrow(Exception.class)
In Mockito, you can simulate the throwing of an exception by a method using doThrow(Exception.class).when(mockedObject).methodCall(). This sets up the behavior that when methodCall is invoked on mockedObject, it will throw the specified exception.

How can you specify a default value for a request parameter in a Spring Boot controller method?

  • Creating a custom annotation.
  • Default values for request parameters are not supported in Spring Boot.
  • Setting the default value in the application.properties file.
  • Using the @RequestParam annotation with the defaultValue attribute.
You can specify a default value for a request parameter in a Spring Boot controller method using the @RequestParam annotation with the defaultValue attribute. This attribute allows you to provide a default value that will be used if the parameter is not present in the request. Setting the default value in the application.properties file is not the correct approach, and creating a custom annotation is not a standard way to specify default values for request parameters.

In Spring Security, which class is primarily responsible for holding the authenticated user’s details?

  • UserDetails
  • UserPrincipal
  • AuthenticationDetails
  • SecurityContext
In Spring Security, the class primarily responsible for holding the authenticated user's details is UserDetails. It represents user information, including username, password, authorities, and account status. SecurityContext is used to hold the security context, and the other options do not typically hold user details.

In Spring Boot, _____ is used to enable caching capability in the application.

  • @CacheConfig
  • @Cacheable
  • @EnableCaching
  • @Caching
In Spring Boot, the @EnableCaching annotation is used to enable caching capability in the application. It allows you to use caching annotations like @Cacheable and @CacheEvict to control caching behavior. The other options are related to caching but not used for enabling caching at the application level.