PrepIQ Spring Web Application Developer Ultimate Exam, Exams of Technology

A comprehensive evaluation for developers building robust Spring-based web applications. Exam topics include Spring MVC architecture, RESTful API creation, exception handling, data persistence with Spring Data, security configuration, dependency injection, and testing frameworks like JUnit and Mockito. Scenarios include implementing CRUD features, optimizing web performance, handling concurrency issues, and designing maintainable application flows. The exam reflects real development challenges for backend and full-stack developers working with Spring Boot and Java web applications.

Typology: Exams

2025/2026

Available from 05/11/2026

shilpi-jain-3
shilpi-jain-3 🇮🇳

2.5

(11)

80K documents

1 / 80

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PrepIQ Spring Web Application Developer
Ultimate Exam
**Question 1.** Which annotation indicates that a class is a candidate for Spring’s
component scanning and should be registered as a bean?
A) @Service
B) @Component
C) @Repository
D) @Controller
Answer: B
Explanation: @Component is the generic stereotype annotation that marks a class
for component scanning; the other three are specializations of @Component.
**Question 2.** In Spring’s Java-based configuration, which annotation is used to
declare a class that contains @Bean-producing methods?
A) @ComponentScan
B) @Configuration
C) @EnableAutoConfiguration
D) @ImportResource
Answer: B
Explanation: @Configuration marks a class as a source of bean definitions; methods
annotated with @Bean inside it are processed by the container.
**Question 3.** What is the default scope of a Spring bean defined with
@Component or @Bean?
A) prototype
B) request
C) session
D) singleton
Answer: D
Explanation: By default, Spring creates a single shared instance (singleton) of each
bean in the container.
**Question 4.** Which of the following statements about @Autowired constructor
injection is true?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50

Partial preview of the text

Download PrepIQ Spring Web Application Developer Ultimate Exam and more Exams Technology in PDF only on Docsity!

Ultimate Exam

Question 1. Which annotation indicates that a class is a candidate for Spring’s component scanning and should be registered as a bean? A) @Service B) @Component C) @Repository D) @Controller Answer: B Explanation: @Component is the generic stereotype annotation that marks a class for component scanning; the other three are specializations of @Component. Question 2. In Spring’s Java-based configuration, which annotation is used to declare a class that contains @Bean-producing methods? A) @ComponentScan B) @Configuration C) @EnableAutoConfiguration D) @ImportResource Answer: B Explanation: @Configuration marks a class as a source of bean definitions; methods annotated with @Bean inside it are processed by the container. Question 3. What is the default scope of a Spring bean defined with @Component or @Bean? A) prototype B) request C) session D) singleton Answer: D Explanation: By default, Spring creates a single shared instance (singleton) of each bean in the container. Question 4. Which of the following statements about @Autowired constructor injection is true?

Ultimate Exam

A) It requires the @Autowired annotation on the constructor only if there is a single constructor. B) It can only be used on private constructors. C) It forces the bean to be prototype scoped. D) It disables circular dependency detection. Answer: A Explanation: When a bean has only one constructor, Spring automatically uses it for injection even without @Autowired; otherwise, the annotation is required. Question 5. How does Spring resolve a bean name conflict when multiple candidates match an @Autowired injection point? A) It throws a NoSuchBeanDefinitionException. B) It selects the bean with the highest @Priority value. C) It picks the bean whose name matches the field name. D) It randomly selects one of the beans. Answer: C Explanation: If multiple beans of the same type exist, Spring first looks for a bean whose name matches the injection point; otherwise, a NoUniqueBeanDefinitionException is thrown. Question 6. Which interface should a bean implement to execute custom logic after all its properties have been set? A) DisposableBean B) InitializingBean C) BeanFactoryAware D) ApplicationListener Answer: B Explanation: Implementing InitializingBean and overriding afterPropertiesSet() allows a bean to run code after dependency injection is complete. Question 7. Which of the following is a correct way to declare a lazy-initialized singleton bean in Java configuration?

Ultimate Exam

C) To provide custom property editors for bean properties. D) To manage the lifecycle of prototype beans. Answer: B Explanation: BeanFactoryPostProcessor operates on the bean definition metadata before any bean instances are created. Question 11. Which of the following statements about Spring’s @Value annotation is correct? A) It can only inject primitive types. B) It supports SpEL expressions inside ${}. C) It requires a PropertySourcesPlaceholderConfigurer bean to work. D) It can inject values only from system environment variables. Answer: C Explanation: @Value resolves placeholders using PropertySourcesPlaceholderConfigurer (or its modern equivalents) to replace ${...} expressions. Question 12. When using Spring Boot, which starter dependency automatically configures an embedded Tomcat server? A) spring-boot-starter-webflux B) spring-boot-starter-data-jpa C) spring-boot-starter-web D) spring-boot-starter-security Answer: C Explanation: spring-boot-starter-web includes spring-boot-starter-tomcat, providing an embedded servlet container. Question 13. Which annotation enables declarative transaction management in a Spring configuration class? A) @Transactional B) @EnableTransactionManagement C) @TransactionManagement

Ultimate Exam

D) @EnableJpaRepositories Answer: B Explanation: @EnableTransactionManagement activates Spring’s annotation-driven transaction management. Question 14. In Spring’s @Transactional annotation, what does propagation = Propagation.REQUIRES_NEW mean? A) Join the existing transaction if present. B) Always start a new transaction, suspending any existing one. C) Never start a transaction; run non-transactionally. D) Throw an exception if there is no existing transaction. Answer: B Explanation: REQUIRES_NEW forces the creation of a new transaction, suspending any current transaction. Question 15. Which isolation level prevents dirty reads but allows non-repeatable reads? A) READ_UNCOMMITTED B) READ_COMMITTED C) REPEATABLE_READ D) SERIALIZABLE Answer: B Explanation: READ_COMMITTED locks rows only for the duration of the read, preventing dirty reads while permitting non-repeatable reads. Question 16. Which Spring Data JPA interface provides CRUD operations plus pagination and sorting? A) CrudRepository B) PagingAndSortingRepository C) JpaRepository D) Repository

Ultimate Exam

Explanation: @ResponseBody tells Spring to write the method’s return value directly to the HTTP response body (typically as JSON or XML). Question 20. Which of the following is NOT a valid way to configure CORS for a Spring MVC controller? A) Using @CrossOrigin on the controller class. B) Defining a CorsConfigurationSource bean. C) Adding a Filter that sets Access-Control-Allow-Origin header manually. D) Setting the “cors.allowed.origins” property in application.properties without any additional configuration. Answer: D Explanation: Spring does not automatically read a “cors.allowed.origins” property; CORS must be configured via annotations, a CorsConfigurationSource, or a custom filter. Question 21. What does the @Profile annotation do when placed on a @Configuration class? A) It indicates that the class should be loaded only when the specified profile is active. B) It marks the class as a candidate for component scanning. C) It forces the bean definitions inside to be prototype scoped. D) It disables bean definition overriding. Answer: A Explanation: @Profile limits the registration of the configuration class (and its beans) to the specified active profile(s). Question 22. Which of the following statements about Spring’s Environment abstraction is true? A) It can only read properties from application.properties. B) It provides a unified way to access property sources and active profiles. C) It replaces the need for @Value annotations. D) It is only available in Spring Boot applications.

Ultimate Exam

Answer: B Explanation: Environment aggregates all property sources (system, env vars, property files, etc.) and exposes active profiles. Question 23. How does Spring resolve a circular dependency when using constructor injection? A) It uses a proxy to break the cycle. B) It throws BeanCurrentlyInCreationException. C) It automatically switches to setter injection. D) It creates both beans as prototype scope. Answer: B Explanation: Constructor injection cannot resolve circular references; Spring detects the cycle and throws BeanCurrentlyInCreationException. Question 24. Which annotation can be used to execute a method after a bean’s dependencies have been injected, but before the bean is put into service? A) @PreDestroy B) @PostConstruct C) @BeforeInitialize D) @AfterInjection Answer: B Explanation: @PostConstruct marks a method to be executed after dependency injection is complete. Question 25. In Spring MVC, which object holds the model attributes to be rendered by a view? A) ModelAndView B) ModelMap C) Model D) All of the above Answer: D

Ultimate Exam

Explanation: By default, Spring rolls back a transaction only for unchecked exceptions. Question 29. In Spring Data JPA, which method name would generate a query to find all users whose email ends with a given domain? A) findByEmailEndingWith(String domain) B) findAllByEmailLike(String pattern) C) findByEmailContaining(String fragment) D) findByEmailEndsWith(String domain) Answer: D Explanation: Spring Data JPA supports the “EndsWith” keyword to generate the appropriate LIKE query. Question 30. Which of the following is a valid way to register a custom BeanPostProcessor? A) Declare it as a @Component. B) Add it to the BeanFactory via beanFactory.addPostProcessor(). C) Define it as a @Bean in a @Configuration class. D) All of the above. Answer: D Explanation: BeanPostProcessor implementations can be registered as regular beans (via @Component, @Bean, or programmatic registration). Question 31. Which annotation enables Spring MVC’s support for handling @RequestBody JSON conversion automatically? A) @EnableWebMvc B) @RestController C) @JsonComponent D) @EnableJackson Answer: A Explanation: @EnableWebMvc registers the necessary HttpMessageConverters (including MappingJackson2HttpMessageConverter) for JSON binding.

Ultimate Exam

Question 32. What does the @PathVariable annotation do in a Spring MVC handler method? A) Binds a request parameter to a method argument. B) Extracts a URI template variable from the request URL. C) Maps a request header to a method argument. D) Binds the request body to a method argument. Answer: B Explanation: @PathVariable pulls values from URI placeholders defined in the @RequestMapping path. Question 33. In Spring Boot, which property controls the server port? A) server.http.port B) spring.server.port C) server.port D) spring.boot.port Answer: C Explanation: The server.port property sets the embedded server’s listening port. Question 34. Which of the following is NOT a valid transaction propagation behavior? A) SUPPORTS B) MANDATORY C) NESTED D) ISOLATED Answer: D Explanation: ISOLATED is not a propagation attribute; isolation is a separate concept. Question 35. Which Spring annotation can be used to inject the currently authenticated principal into a controller method argument?

Ultimate Exam

B) To replace the DispatcherServlet. C) To configure view resolvers. D) To automatically serialize response bodies. Answer: A Explanation: HandlerInterceptor provides preHandle, postHandle, and afterCompletion callbacks around request processing. Question 39. Which annotation tells Spring to scan the specified packages for components? A) @ComponentScan(basePackages = "com.example") B) @EnableComponentScanning("com.example") C) @ScanComponents("com.example") D) @AutoComponentScan("com.example") Answer: A Explanation: @ComponentScan configures the packages that Spring will search for stereotype-annotated classes. Question 40. Which of the following is true about CGLIB proxies in Spring AOP? A) They can proxy interfaces only. B) They require the target class to be non-final and have a default constructor. C) They are used when the bean implements at least one interface. D) They cannot advise private methods. Answer: B Explanation: CGLIB creates subclass proxies, so the target class must be non-final and have a no-arg constructor (or one that can be instantiated). Question 41. What is the effect of annotating a bean method with @Scope("prototype") in a @Configuration class? A) The bean will be created once per HTTP request. B) A new instance will be returned each time it is requested from the container. C) The bean will be shared across the entire application context.

Ultimate Exam

D) The bean will be lazily initialized only when first needed. Answer: B Explanation: Prototype scope means the container creates a fresh instance on each request for the bean. Question 42. Which of the following is the correct syntax for a SpEL expression that concatenates two strings? A) #{'Hello' + 'World'} B) ${'Hello' + 'World'} C) #{'Hello'.concat('World')} D) Both A and C Answer: D Explanation: Both the + operator and the concat() method are valid in SpEL within #{...}. Question 43. In Spring Boot, which starter dependency provides support for building RESTful web services using Spring MVC? A) spring-boot-starter-webflux B) spring-boot-starter-web C) spring-boot-starter-data-rest D) spring-boot-starter-actuator Answer: B Explanation: spring-boot-starter-web brings in Spring MVC, Jackson, and an embedded servlet container for REST APIs. Question 44. Which annotation can be placed on a Spring MVC method to specify that it produces JSON output? A) @Produces("application/json") B) @ResponseBody(produces = "application/json") C) @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) D) @RequestMapping(consumes = MediaType.APPLICATION_JSON_VALUE)

Ultimate Exam

Explanation: @RequestParam extracts values from query strings or posted form data. Question 48. Which component of Spring MVC is responsible for converting a request body (e.g., JSON) into a Java object? A) ViewResolver B) HttpMessageConverter C) HandlerMapping D) ModelAndViewResolver Answer: B Explanation: HttpMessageConverter implementations (e.g., MappingJackson2HttpMessageConverter) perform body-to-object conversion. Question 49. What does the @EnableJpaRepositories annotation do? A) Scans for JPA entity classes. B) Enables the creation of Spring Data JPA repository implementations. C) Configures the EntityManagerFactory automatically. D) Registers a JdbcTemplate bean. Answer: B Explanation: @EnableJpaRepositories triggers scanning for interfaces extending Repository and creates proxy implementations. Question 50. Which of the following is true about Spring’s @Scheduled annotation? A) It can only be used on methods returning void. B) It requires a cron expression or fixedDelay/fixedRate attribute. C) It automatically creates a ThreadPoolTaskScheduler bean. D) It can be applied to constructors. Answer: B Explanation: @Scheduled must be configured with a schedule definition such as cron, fixedDelay, or fixedRate.

Ultimate Exam

Question 51. In a Spring MVC application, which object determines which controller method will handle a given request? A) DispatcherServlet B) HandlerAdapter C) HandlerMapping D) ViewResolver Answer: C Explanation: HandlerMapping maps incoming requests to appropriate handler methods. Question 52. Which of the following annotations marks a method to be executed before a @Transactional method, but within the same transaction? A) @BeforeTransaction B) @TransactionalEventListener(phase = BEFORE_COMMIT) C) @PreAuthorize D) @Before Answer: B Explanation: @TransactionalEventListener with phase=BEFORE_COMMIT runs just before the transaction commits, still inside the transaction. Question 53. Which of the following statements about Spring’s @ControllerAdvice is correct? A) It can only be used to define @ExceptionHandler methods. B) It allows global handling of @ExceptionHandler, @InitBinder, and @ModelAttribute methods. C) It replaces the need for @RestController. D) It must be placed in the same package as the controllers. Answer: B Explanation: @ControllerAdvice applies globally to all controllers for exception handling, data binding, and model attributes.

Ultimate Exam

A) It prevents the field from being persisted to the database. B) It excludes the field from JSON serialization and deserialization. C) It marks the field as transient for Java serialization. D) It hides the field from Spring’s component scanning. Answer: B Explanation: @JsonIgnore (from Jackson) tells the JSON processor to ignore the annotated property. Question 58. Which of the following is a valid way to configure a DataSource bean in a Spring Boot application without using application.properties? A) Define a @Bean method returning DataSource in a @Configuration class. B) Create a file named datasource.xml in the classpath. C) Use @EnableDataSourceAutoConfiguration. D) Set the datasource URL as a system property only. Answer: A Explanation: Providing a @Bean of type DataSource overrides the auto-configured DataSource. Question 59. In Spring AOP, what does the term “join point” refer to? A) The point where two aspects intersect. B) A specific execution point such as method invocation. C) The configuration file that joins beans together. D) The class that contains the advice methods. Answer: B Explanation: A join point is a point during program execution (e.g., method call) where advice can be applied. Question 60. Which of the following statements about @Transactional(readOnly = true) is correct? A) It guarantees that no write operations will be performed.

Ultimate Exam

B) It hints to the underlying database that the transaction can be optimized for reads. C) It disables transaction management entirely. D) It forces the transaction to use the SERIALIZABLE isolation level. Answer: B Explanation: readOnly=true is a hint that can allow the database to apply read-only optimizations; it does not enforce write protection at the Java level. Question 61. Which of the following is the correct way to declare a bean that should be initialized after the container has started, using @PostConstruct? A) @PostConstruct public void init() { … } B) @AfterInitialize public void init() { … } C) @Bean(initMethod = "init") D) Both A and C are valid. Answer: D Explanation: @PostConstruct marks a method to be called after dependency injection; alternatively, initMethod attribute on @Bean achieves the same. Question 62. In Spring MVC, which annotation is used to map a handler method to handle HTTP DELETE requests? A) @DeleteMapping B) @RequestMapping(method = RequestMethod.DELETE) C) Both A and B D) @RemoveMapping Answer: C Explanation: Both @DeleteMapping (shortcut) and @RequestMapping with method=DELETE are valid. Question 63. Which of the following is NOT a built-in Spring MVC view technology? A) Thymeleaf B) JSP