CoreHRx Jobs

Apply in one click, save jobs and take free mock tests.

Register free Log in
Hiring? Post jobs with CoreHRx
My account
user

View & update profile

Java and Spring Boot mock test: free online practice

15 to 30 random questions in 15 to 30 minutes, by the level you choose: core java, collections, concurrency, spring boot and jpa. After you submit you get your score, your strong and weak topics, and the right answer with an explanation for every question.

Want to revise first? Read the Java and Spring Boot interview questions and answers.

Choose your experience

Free with a CoreHRx Jobs account: you will be asked to sign in or create one first.

What does the Java and Spring Boot mock test cover?

The test covers 12 topics across three levels. Each attempt picks 15 to 30 questions at random, by the level you choose, so every attempt is different.

  • Collections
  • Concurrency
  • Core Java
  • JPA
  • JVM
  • Microservices
  • OOP
  • REST APIs
  • Security
  • Spring Boot
  • Spring Core
  • Streams

Sample Java and Spring Boot mock test questions

One question from each level, the way they appear in the test. A new set comes on the 1st of every month. Try it, then open the answer.

  1. FresherStreams

    What happens when this code runs?

    Stream<Integer> s = Stream.of(1, 2, 3);
    System.out.println(s.count());
    System.out.println(s.count());
    • It prints 3 twice
    • It prints 3 and then 0, because the stream is empty after the first count()
    • It prints 3, then throws IllegalStateException on the second count()
    • It fails to compile because s is used twice
    Show the answer

    Answer: It prints 3, then throws IllegalStateException on the second count(). A stream can be consumed only once. After the terminal operation count() the stream is closed, and any further operation throws IllegalStateException: stream has already been operated upon or closed. Create a new stream from the source each time you need one.

  2. Intermediate (1-5 years)JPA

    Is the new name saved to the database when this method completes?

    @Transactional
    public void rename(Long id, String name) {
        Employee e = repository.findById(id).orElseThrow();
        e.setName(name);
    }
    • Yes, but only if the entity class overrides equals() and hashCode()
    • No; changes are written only when the application shuts down
    • No; repository.save(e) must be called to write the change
    • Yes; the entity is managed, so dirty checking updates it at commit
    Show the answer

    Answer: Yes; the entity is managed, so dirty checking updates it at commit. Inside a transaction, entities loaded through the persistence context are managed. At flush time Hibernate compares them to their loaded snapshot and issues an UPDATE for changed fields. Calling save() here is harmless but unnecessary; outside a transaction the change would not be tracked.

  3. Experienced (5+ years)Spring Boot

    During every rolling deploy on Kubernetes, a few in-flight requests fail with connection resets when old pods terminate. What is the right fix?

    • Graceful shutdown plus a short preStop delay so the pod leaves the load balancer first
    • Increase the number of replicas so that each pod handles fewer requests during deploys
    • Disable the liveness probe during deployments so that pods are never restarted early
    • Set server.tomcat.threads.max higher so that in-flight requests finish more quickly
    Show the answer

    Answer: Graceful shutdown plus a short preStop delay so the pod leaves the load balancer first. On SIGTERM the pod may still receive traffic for a moment while endpoints update. A preStop sleep covers that window, and graceful shutdown (server.shutdown=graceful, the default since Boot 3.4) stops accepting new requests and waits for active ones up to spring.lifecycle.timeout-per-shutdown-phase.

Take the full Java and Spring Boot mock test: 15 to 30 questions and 15 to 30 minutes, by level.

How is the Java and Spring Boot mock test scored?

A question counts as right only when you pick exactly the right option, or all the right options where it says so; a question left blank counts as wrong. Your score is the share of the test's questions you got right (15 to 30, by level). The result also scores every topic, so you know what to revise before the interview.

  • 75% or more in a topica strength
  • 50% to 74%worth a revision
  • Under 50%a topic to work on

Java and Spring Boot mock test: questions people ask

Is the Java and Spring Boot mock test free?

Yes. The Java and Spring Boot mock test is free. You need a free CoreHRx Jobs account to start it, so your score and the topics to work on are saved.

How many questions are in the Java and Spring Boot mock test?

It depends on the level: Fresher has 15 questions in 15 minutes, Intermediate has 20 questions in 20 minutes, Experienced has 30 questions in 30 minutes. They are multiple-choice questions picked at random from a larger bank of Java and Spring Boot questions at your level, so every attempt is different.

Which Java and Spring Boot topics does the test cover?

The questions cover Collections, Concurrency, Core Java, JPA, JVM, Microservices, OOP, REST APIs, Security, Spring Boot, Spring Core, Streams. Your result shows how you did in each topic.

Which level should I choose?

Fresher if you are a student or have less than a year of experience, Intermediate for 1 to 5 years at work, and Experienced for 5 years or more.

Can employers see my Java and Spring Boot score?

Only your best Java and Spring Boot score, and only when it is 60% or more. It shows on the job applications you send on CoreHRx. Lower scores stay private.

Can I take the Java and Spring Boot mock test again?

Yes, up to 10 tests a day. Each attempt picks questions you have not seen recently first.

All mock tests