readyforhires

Intermediate Spring Boot test (Intermediate)

30 questions · 35 minutes · Free

Data JPA, transactions, validation, security basics and testing.

Take the Intermediate Spring Boot test

What it covers

Interview format

Earn a certificate

The Intermediate Spring Boot test is one of the 8 tests of the Software Engineer (Java): Intermediate learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for Software Engineer (Java): Intermediate, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Intermediate Spring Boot test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. Which of the following statements correctly describes the behavior of the @Transactional annotation with propagation = Propagation.REQUIRES_NEW?

    1. The @Transactional annotation with propagation = Propagation.REQUIRES_NEW will merge the new transaction into the existing transaction.
    2. The @Transactional annotation with propagation = Propagation.REQUIRES_NEW will not start a new transaction if called within an existing transaction.
    3. The @Transactional annotation with propagation = Propagation.REQUIRES_NEW will start a new transaction, even if called within an existing transaction.
    4. The @Transactional annotation with propagation = Propagation.REQUIRES_NEW will roll back the existing transaction if an exception occurs.

    Answer: C. The @Transactional annotation with propagation = Propagation.REQUIRES_NEW will start a new transaction, even if called within an existing transaction.

    The propagation behavior of a transaction determines how a transaction is managed when a method is called within another transaction. When propagation is set to REQUIRES_NEW, a new transaction is always started, even if there is an existing transaction. This ensures that the method runs in isolation from the parent transaction.

  2. Which of the following method names would Spring Data JPA correctly derive a JPQL query to find all entities where the 'lastName' property starts with a given string?

    1. findAllByLastNameStarts
    2. findAllByLastNameStartWith
    3. findAllByLastNameStartingWith
    4. findAllByLastNameStartsAt

    Answer: C. findAllByLastNameStartingWith

    Spring Data JPA derives queries based on method names. The method name 'findAllByLastNameStartingWith' correctly maps to a JPQL query that finds all entities where the 'lastName' property starts with a given string. The other options either have incorrect syntax or do not align with the standard query derivation rules.

  3. What is the correct state of an entity after it has been successfully saved to the database using Spring Data JPA?

    1. The entity is in the 'persistent' state after being saved to the database.
    2. The entity is in the 'transient' state after being saved to the database.
    3. The entity is in the 'detached' state after being saved to the database.
    4. The entity is in the 'removed' state after being saved to the database.

    Answer: A. The entity is in the 'persistent' state after being saved to the database.

    In the Spring Data JPA lifecycle, an entity becomes 'persistent' after it is saved to the database. This is a common edge case where developers might mistakenly assume the entity is in the 'transient' state after saving. The other options either describe incorrect states or misrepresent the lifecycle.

  4. You are working on a Spring Boot project that uses Spring Data JPA to manage a 'User' entity with a 'lastName' field. You need to create a repository method that returns all users whose last names start with a given string. Which of the following method names correctly derives the appropriate JPQL query for this requirement?

    1. findAllByLastNameLike
    2. findAllByLastNameStartingWith
    3. findAllByLastNameStartWith
    4. findAllByLastNameStartsWith

    Answer: B. findAllByLastNameStartingWith

    In Spring Data JPA, the method name 'findAllByLastNameStartingWith' correctly derives a JPQL query to find all entities where the 'lastName' property starts with a specified string. The other options either use incorrect syntax or do not match the expected query derivation rules.

  5. Which of the following annotations ensures that a method will always run in a new transaction, even if it is called from within an existing transaction?

    1. The method is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW)
    2. The method is annotated with @Transactional(propagation = Propagation.NOT_SUPPORTED)
    3. The method is annotated with @Transactional(propagation = Propagation.SUPPORTS)
    4. The method is annotated with @Transactional(propagation = Propagation.NESTED)

    Answer: A. The method is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW)

    When a method is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW), it ensures that the method will always run in a new transaction, even if it is called from within an existing transaction. This is useful for scenarios where you want to isolate the operations of one method from another, ensuring that any changes made in this method do not affect the transaction of the calling method.

Frequently asked questions

How many questions are in the Intermediate Spring Boot test?
30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
What does the Intermediate Spring Boot test cover?
Spring Data JPA and transactions, Validation and exception handling, Spring Security basics, Testing with MockMvc, Actuator and metrics.
Is the Intermediate Spring Boot test free?
Yes. It is free to take with a readyforhires account.
What level is the Intermediate Spring Boot test?
Intermediate, in Backend.

More Backend tests

Roles that test these skills

Companies that test these skills

All practice tests · All Backend tests

Last updated