VMware

Spring Professional Develop

2V0-72.22

Prepare for the 2V0-72.22 exam to validate your skills in Spring Professional development.

192 questions 0 views Free
Start Mock Test Timed · Full-length · Scored

Questions 171–180 of 192

Q171

What happens when a Spring Bean is marked as @Scope(value = "prototype")?

  • A Single instance per application
  • B New instance every request
  • C Shared among multiple requests
  • D Disposed after each request
Explanation @Scope(value = "prototype") creates a new bean instance for every request, unlike singleton scope.
Q172

Which Spring component is primarily used for dependency injection?

  • A ApplicationContext
  • B ModelAndView
  • C InitBinder
  • D JdbcTemplate
Explanation ApplicationContext is responsible for managing bean lifecycle and injecting dependencies; the others serve different purposes.
Q173

A company needs to implement fault tolerance. Which Spring feature should they use?

  • A Spring Boot Actuator
  • B Spring Retry
  • C Spring Webflux
  • D Spring AOP
Explanation Spring Retry allows for automatic retry of operations that fail, while the others support different functionalities.
Q174

You are configuring a Spring application. What happens when you annotate a method with @Transactional?

  • A It defines a new transaction.
  • B It rolls back on any exception.
  • C It requires database access.
  • D It enforces lazy loading.
Explanation The @Transactional annotation ensures the method's transactions will roll back on unhandled exceptions; the other options mischaracterize its behavior.
Q175

Which service in Spring allows asynchronous method execution?

  • A @Async
  • B @Controller
  • C @Repository
  • D @Value
Explanation @Async allows methods to run asynchronously, while other annotations serve different purposes.
Q176

A company needs to handle large data in a streaming fashion. Which Spring module is best suited for this requirement?

  • A Spring Batch
  • B Spring Data JPA
  • C Spring WebFlux
  • D Spring MVC
Explanation Spring WebFlux supports reactive programming, making it ideal for data streaming, unlike others.
Q177

What happens when you annotate a configuration class with @ComponentScan but omit base packages?

  • A Only package specified is scanned.
  • B No beans are detected.
  • C Scans current package and sub-packages.
  • D Throws a configuration error.
Explanation Omitting base packages defaults to scanning the package of the configuration class, unlike the others.
Q178

Which service allows for dependency injection in Spring?

  • A Spring IoC Container
  • B Spring AOP
  • C Spring MVC
  • D Spring Data
Explanation The Spring IoC Container manages the instantiation and lifecycle of beans, enabling dependency injection. The other options serve different purposes such as aspects, web applications, or data access.
Q179

A company needs to externalize configuration properties in a Spring application. What approach should they take?

  • A Use application.properties file
  • B Hard-code properties in classes
  • C Use environment variables exclusively
  • D Ignore externalization, use defaults
Explanation The application.properties file allows for flexible configuration management while the other options lack portability or proper management.
Q180

You are configuring a Spring Boot application to use profiles. What happens when a profile is activated?

  • A Overrides default properties
  • B Disables application context
  • C Always adds new beans
  • D Stops the application from running
Explanation Activating a profile overrides default properties, while the other options don't describe typical profile behavior.