10 Free Spring Professional Certification Practice Questions and Answers
Tags: spring, springboot, programming, certification
Published: 2023-01-21 09:07:01

---
title: 10 Free Spring Professional Certification Practice Questions and Answers
published: true
description: Free Spring Framework Practice Questions with answers and explanations for Java developers
tags: spring, springboot, programming, certification
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k0row531xy6rppxd1ndt.jpeg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-21 08:51 +0000
---
*Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.*

Hello Java developers, are you preparing for IT certification like Oracle's [Java certification](https://javarevisited.blogspot.com/2019/12/how-to-crack-java-se-11-certification.html) or Vmware's Spring Certification required a lot of hard-work. 

I have seen many experienced Java developers failing these certifications and losing money and time due to over-confidence and lack of preparation. **A structured and complete certification preparation involves reading books, joining course and doing practice questions**. 

When it comes to Spring certification, practice questions are quite hard to find and that's why I created my [**Udemy course with 250+ Spring Certification questions**](https://www.udemy.com/course/spring-professional-practice-test-questions-vmware-edu-certification/?referralCode=7419B0A2C8AB79F0520E). This course has helped more than 9000 students in their Spring certification preparation journey.

Since many of you asked me about **Free Spring certification questions**, I decided to post 50 practice questions from my paid Spring certification course for FREE in a series of articles, just for you, my readers and motivators.

This also makes a lot of sense because I have in past used many [free resources](https://www.java67.com/2017/08/3-free-spring-certification-mock-exams-practice-questions.html) to pass my own Java and Spring certification and this way I can give something back to the community.

It will also helps me to get more feedback to improve the paid course even better to provide better learning experience to people who have trusted me with their money.

By the way, if you are in hurry, you can always join the full course on Udemy where you will get all questions and answers and start practicing with Udemy's exam simulator.

In the [full course]((https://www.udemy.com/course/spring-professional-practice-test-questions-vmware-edu-certification/?referralCode=7419B0A2C8AB79F0520E)) you will get:

-   5 Full length practice tests
-   250+ Questions with Answers and explanations
-   Topic wise questions like you can practice all spring boot or spring security questions
-   Lifetime access
-   30-days money back guarantee with no questions asked

If you like to buy the course you can [**use this link to buy the course**](https://www.udemy.com/course/spring-professional-practice-test-questions-vmware-edu-certification/?referralCode=7419B0A2C8AB79F0520E) with the best price available. I usually give $9.9 discount coupon to my readers, so if you ever need, you can always ask in the comments below or you can drop me an email.

[![50 Free Spring Professional Certification Practice Questions with Answers and Explanations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k0row531xy6rppxd1ndt.jpeg)](https://www.udemy.com/course/spring-professional-practice-test-questions-vmware-edu-certification/?referralCode=7419B0A2C8AB79F0520E)

------


##10 Spring Framework Practice Questions Answers and Explanations
Here is 10 Spring questions you can solve or practice as part of your Spring professional certification. 

These questions are from full length test which means they cover almost every topics like [Core Spring](https://javarevisited.blogspot.com/2018/06/top-6-spring-framework-online-courses-Java-programmers.html), Bean lifecycle, [AOP](https://javarevisited.blogspot.com/2021/03/spring-aop-interview-questions-answers.html), [Spring Boot](https://javarevisited.blogspot.com/2020/05/top-20-spring-boot-interview-questions-answers.html), [Testing](https://javarevisited.blogspot.com/2021/02/-spring-boot-testing-interview-questions-answers-java.html), [Microservices](https://www.java67.com/2021/02/microservices-interview-questions-answers-java-spring.html), [Spring Data JPA](https://javarevisited.blogspot.com/2022/06/spring-data-jpa-interview-questions.html) and more.

**1\. Which of the following Spring MVC-related information types are collected in metrics by Spring Boot Actuator by default?**

1\. Requesting user

2\. HTTP method

3\. Accessed endpoint

4\. Response status

Correct answer is 2,3,4

Explanation: By default, Spring MVC-related metrics are tagged with the following information:

-   exception - Simple class name of any exception that was thrown while handling the request.
-   method - Request' s method (for example, [GET](https://javarevisited.blogspot.com/2012/03/get-post-method-in-http-and-https.html) or [POST](https://javarevisited.blogspot.com/2016/10/difference-between-put-and-post-in-restful-web-service.html))
-   outcome - Request's outcome based on the status code of the response. 1xx is INFORMATIONAL, 2xx is SUCCESS, 3xx is REDIRECTION, 4xx CLIENT_ERROR, and 5xx is SERVER_ERROR
-   status - Response's HTTP status code (for example, 200 or 500)
-   uri - Requests URI template prior to variable substitution, if possible (for example, /api/person/{id})

------


**2\. What do SpEL expressions starting with # reference?**

1\. Properties in the application environment

2\. Spring Beans

3\. Literal Values

4\. JVM Properties

Correct Answer is 2 "Spring Beans"

Explanation: "A Spring bean is referenced using its name prefixed with @ in SpEL. Chains of property

references can be accessed using the period character.

-   Example accessing property on Spring bean: @mySuperComponent.injectedValue
-   Example invoking method on Spring bean: @mySuperComponent.toString()

------


**3\. Which of the following methods will be called first in the bean lifecycle?**

1\. afterPropertiesSet method in InitializingBean interface

2\. init-method as specified in the Spring XML Configuration

3\. Any methods annotated with @PostConstruct

4\. Any method named "init"

Correct Answer is 3"Any methods annotated with @PostConstruct"

Explanation: For each bean in the container the lifecycle happens as follows:

An instance of the bean is created using the bean metadata.

Properties and dependencies of the bean are set.

Any instances of BeanPostProcessor are given a chance to process the new bean

instance before and after initialization.

- Any methods in the bean implementation class annotated with @PostConstruct are

invoked.

This processing is performed by a BeanPostProcessor.

- Any afterPropertiesSet method in a bean implementation class implementing the

InitializingBean interface is invoked.

This processing is performed by a BeanPostProcessor. If the same initialization

method has already been invoked, it will not be invoked again.

- Any custom bean initialization method is invoked.

Bean initialization methods can be specified either in the value of the init-method

attribute in the corresponding <bean> element in a Spring XML configuration or in

the initMethod property of the [@Bean annotation.](https://www.java67.com/2021/10/pring-bean-example-what-does-bean-annotation-does.html)

This processing is performed by a BeanPostProcessor. If the same initialization

method has already been invoked, it will not be invoked again.

- The bean is ready for use.

------


**4\. Which of the following are auto-configured when using @DataJpaTest?**

1\. Spring Repositories

2\. Spring Security

3\. DataSource

4\. Message source

Correct Answer is 1,3

Explanation: "The [@DataJpaTest](https://javarevisited.blogspot.com/2021/09/difference-between-webmvctest-and-da.html) annotation auto-configures the following:

- Caching

- Spring Data JPA repositories

- Flyway database migration tool

- A DataSource - The data-source will, as default, use an embedded in-memory database (test database).

- Data source transaction manager - A transaction manager for a single DataSource.

- A JdbcTemplate

- Liquibase database migration tool

- JPA based configuration for [Hibernate](https://javarevisited.blogspot.com/2018/01/top-5-hibernate-and-jpa-courses-for-java-programmers-learn-online.html)

- Spring transaction

- A test database

- A JPA entity manager for tests

-------


**5\. What one of these ensures that if anything goes wrong, the changes will be preserved once the system is back?**

1\. Atomicity

2\. Consistency

3\. Isolation

4\. Durability

Correct Answer: 4

Explanation: The effect of one transaction will not have any impact on another [transaction](https://javarevisited.blogspot.com/2011/11/database-transaction-tutorial-example.html) so they are independent to one another. They are totally isolated from one another.


-------


**6\. Which of the following properties are required in order to configure an external MySQL Database?**

1\. spring.datasource.password

2\. spring.datasource.username

3\. spring.datasource.url

4\. spring.datasource.driver-class-name

Correct Answer: 1,2,3,4

Explanation: All of these are required. Depending on the Database Provider, sometimes it is not necessary to provide the driver-class-name.

-------


**7\. Which class is used for programmatic usage of transactions?**

1\. TransactionTemplate

2\. TransactionExecutor

3\. @Transactional

4\. RollbackManager

Correct Answer: 1

Explanation: [@Transactional](https://javarevisited.blogspot.com/2021/08/spring-transactional-example-how-to.html) annotation in Spring is used for declarative usage, not programmatic.

-------


**8\. What effect does setting the attribute "readOnly" on the @Transactional annotation to true have?**

1\. It does not allow write operations

2\. It may optimize query performance

3\. Sets the lock mode to READ

4\. Nothing. It is there only for documentation.

Correct Answer is 2  "

Explanation: Only some databases reject the INSERT and UPDATE statements inside a read only transaction.


------


**9\. Which of the following does Spring Boot provide regarding error handling?**

1\. Global error page

2\. JSON error response

3\. Checked exceptions for most common problems

4\. Logging errors stack traces separately

Correct Answer: 1,2

Explanation: By default, Spring Boot provides an /error mapping that handles all errors in a sensible way, and it is registered as a "global error page" in the servlet container. For machine clients, it produces a [JSON response](https://javarevisited.blogspot.com/2022/03/how-to-send-json-via-post-request-using.html) with details of the error, the HTTP status, and the exception message. 

For browser clients, there is a "whitelabel" error view that renders the same data in HTML format (to customize it, add a View that resolves to error).  Spring only throws [unchecked exceptions](https://javarevisited.blogspot.sg/2011/12/checked-vs-unchecked-exception-in-java.html) in the case of problems.

-----

**10\. Which of the following are web environment options offered by @SpringBootTest?**

1\. RANDOM_PORT

2\. WEB

3\. MINIMAL

4\. DEFINED_PORT

Correct Answer: 1,4

Explanation: Four different types of web environments can be specified using the webEnvironment attribute of the @SpringBootTest annotation:

-   MOCK - Loads a web ApplicationContext and provides a mock web environment. Does not start a web server.
-   RANDOM_PORT - Loads a WebServerApplicationContext, provides a real web environment and starts an [embedded web server](https://www.java67.com/2019/07/spring-boot-3-ways-to-change-port-of-tomcat.html) listening on a random port. The port allocated can be obtained using the @LocalServerPort annotation or @Value(""${local.server.port}""). Web server runs in a separate thread and server-side transactions will not be rolled back in transactional tests.
-   DEFINED_PORT - Loads a WebServerApplicationContext, provides a real web environment and starts an embedded web server listening on the port configured in the application properties, or port 8080 if no such configuration exists. Web server runs in a separate thread and server-side transactions will not be rolled back in transactional tests.
-   NONE - Loads an ApplicationContext without providing any web environment.


That's all in this **first list of 10 Spring Questions for practice**. In the next list I will share 10 more question, I Am also thinking to categories them on topics like Spring Data JPA questions, Spring security questions, and Spring MVC questions for better learning experience. If you like guys like that way, I will do accordingly.

All the best with your Spring certification preparation.

Other **Interview Questions** and Articles for Java programmer:

-   [The Java Developer RoadMap](https://javarevisited.blogspot.com/2019/10/the-java-developer-roadmap.html) 
-   [10 Spring MVC and REST annotations for Java Programmers](https://www.java67.com/2019/04/top-10-spring-mvc-and-rest-annotations-examples-java.html) 
-   [20+ Advanced Spring MVC Interview Questions](https://javarevisited.blogspot.com/2018/11/top-20-spring-mvc-interview-questions-answers-for-java-developers.html#axzz5aKI6DjLZ) 
-   [10 Free Spring Courses for Java developers](https://medium.com/javarevisited/top-10-free-courses-to-learn-spring-framework-for-java-developers-639db9348d25)
-   [20 Spring REST Interview Questions for Java developers](https://javarevisited.blogspot.com/2018/02/top-20-spring-rest-interview-questions-answers-java.html)
-   [10 Free Tutorials and Courses to learn Spring Boot ](https://medium.com/javarevisited/10-free-spring-boot-tutorials-and-courses-for-java-developers-53dfe084587e)
-   [10 Java Coding Interview Questions and Answer](http://java67.blogspot.sg/2012/08/10-java-coding-interview-questions-and.html)
-   [5 Books to learn Spring Framework better](https://javarevisited.blogspot.com/2013/03/5-good-books-to-learn-spring-framework-mvc-java-programmer.html)
-   [10 Best Courses to learn Spring Framework ](https://medium.com/javarevisited/10-best-online-courses-to-learn-spring-framework-in-2020-f7f73599c2fd)
-   [How to implement Role-based access control in Spring?](https://javarevisited.blogspot.com/2013/07/role-based-access-control-using-spring-security-ldap-authorities-mapping-mvc.html)
-   [5 Courses to learn Learn Spring in-depth](https://javarevisited.blogspot.com/2018/06/top-6-spring-framework-online-courses-Java-programmers.html)
-   [Difference between Dependency Injection and Factory Pattern](https://javarevisited.blogspot.com/2015/06/difference-between-dependency-injection.html)
-   [10 Advanced Spring Boot Courses for Java developers](https://medium.com/javarevisited/10-advanced-spring-boot-courses-for-experienced-java-developers-5e57606816bd)
-   [5 Free Courses to learn Core Spring and Spring Boot](https://pluralsight.pxf.io/c/1193463/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fwhats-new-spring-5)
-   [10 Things Java Developers Should Learn](https://javarevisited.blogspot.com/2017/12/10-things-java-programmers-should-learn.html#axzz5atl0BngO) 
-   [5 Java and Web Development Frameworks You can learn](https://javarevisited.blogspot.com/2018/04/top-5-java-frameworks-to-learn-in-2018_27.html#axzz5gF6iu1RE)


**P.S.** - If you want to learn Spring 6 and Spring Boot 4 from scratch in a guided, code-focused way, I also suggest you check out Eugen Paraschiv's [**Learn Spring: The Master Class**](https://courses.baeldung.com/p/ls-master-class?utm_source=javarevisited&utm_medium=web&utm_campaign=lss&affcode=22136_bkwjs9xa) for more in-depth learning of spring framework.