Top Java/Microservice Developer Interview Questions asked in interviews series — 11(Java-8, Spring-Boot, Microservices)

Hello folks, Thanks for reading my articles. This article will again contain the Questions and answers of the Java Developer interview.

Ajay Rathod
4 min readNov 28, 2022

(A bit of context: I’ve conducted numerous interviews for software engineering positions in most of the MNCs. Additionally, there have been instances where I faced challenges during coding interviews due to lack of preparation.)

Are you preparing for a job interview as a Java developer?

Find my book Guide To Clear Java Developer Interview here Gumroad (PDF Format) and Amazon (Kindle eBook).

Guide To Clear Spring-Boot Microservice Interview here Gumroad (PDF Format) and Amazon (Kindle eBook).

Download the sample copy here: Guide To Clear Java Developer Interview[Free Sample Copy]

Guide To Clear Spring-Boot Microservice Interview[Free Sample Copy]

By Ajay Rathod

Java

What are lambda expressions and their use in java 8?

What is a functional interface?
What are the features of Java 8 and Java 11?

How to sort the employee list in ascending and descending order using java 8 streams API?

Ascending order —

List<Integer> sortedList = list.stream().sorted().collect(Collectors.toList());

descending order-

List<Integer> sortedList = list.stream() .sorted(Collections.reverseOrder()) .collect(Collectors.toList());

How to use sorting in java 8?

Using sorted methods we can sort all kinds of sorting

Can we write j-units for static methods?

Yes, we can do that using the Mockito framework, but it will lead to code smell in our code.

Spring Boot

How does the filter work in spring?
What will you use to create resources in the spring boot app post or put?
How to use the put and post methods in spring boot which one is good?

What are the idempotent methods in REST?

REST APIs use HTTP methods such as POST, PUT, and GET to interact with resources such as an image, customer name, or document. When using an idempotent method, the method can be called multiple times without changing the result.

HTTP methods include:

  • POST — Creates a new resource. POST is not idempotent and it is not safe.
  • GET — Retrieves a resource. GET is idempotent and it is safe.
  • HEAD — Retrieves a resource (without response body). HEAD is idempotent and it is safe
  • PUT — Updates/replaces a resource. PUT is idempotent but it is not safe
  • PATCH — Partially updates a resource. PATCH is not idempotent and it is not safe.
  • DELETE — Deletes a resource. DELETE is idempotent but it is not safe.
  • TRACE — Performs a loop-back test. TRACE is idempotent but it is not safe.

How to make post method idempotent inside spring boot?

The simplest way would be just to check at the service level whether a post with a given information exists (as you pointed out). You can use the repository.exists() variations for that.
if multiple requests (original and duplicate request) comes at the same time, both will check in the database and would not find any record with that identifier and will create 2 records (one for each)
You need to isolate the transactions from each other if it is a single database (I know you said it is not, but I’m trying to explain my reasoning so bear with me). For that spring has the following annotation:
@Transactional(isolation = Isolation.SERIALIZABLE). Although in this case, @Transactional(isolation = Isolation.REPEATABLE_READ) would be enough.

How to use a custom exception handler in spring Boot?
How to use
@controladvice for the exception handler?
How to use transaction management in spring boot?
How to handle security in spring-boot?
What is a JWT token and how does spring boot fetch that information from spring boot?
Can singleton bean scope handle multiple parallel requests?
is singleton bean scope thread-safe?

the answer is no, you have to make it thread-safe and by default, it's not safe.
How to make it thread-safe.
Difference between
@component and @service and @repository annotations?
Tell me the Design pattern used inside the spring framework.

these are the common pattern found in spring

  1. Singleton pattern.
  2. Factory Method pattern.
  3. Proxy pattern.
  4. Template pattern.

How do factory design patterns work in terms of the spring framework?
How proxy design pattern is used spring.
Spring transaction management?
Hibernate complex join questions?
How does jwt token authentication work?

The above list of questions has been asked recently in a fintech company interview. please go through it as they are good pointers to search the topic and add depth to your knowledge.

Thanks for reading

  • 👏 Please clap for the story and follow me 👉
  • 📰 Read more content on my Medium (21 stories on Java Developer interview)

Find my books here:

--

--

Ajay Rathod

Software Engineer @Cisco | Java Programmer | AWS Certified | Writer | Find My Books on Java Interview here - https://rathodajay10.gumroad.com/