Top 35 Java Interview Questions for 1 to 3 Years Experienced Developers

Here is the list of some useful Java interview questions for experienced Java programmers having experience in range of 2 to 5 years. As an experienced developer you are expected to learn about OOP concepts, Java basics, Java Collection framework, Multi-threading and Concurrency utilities introduced in Java 5 and 6, Debugging Java application, Algorithm and Data structure, Some questions on design patterns, JVM and Garbage collection and couple of puzzles.

Actually its mix of everything you do in your day to day work.

If you are going for Java developer with some exposure on web development you will also be asked about popular Java frameworks like Spring, Hibernate, Struts 2.0 and others.

If you have more than 5 years of experience you can also expect questions about build tools like Maven, ANT and Gradle, Java best practices, Unit testing and JUnit and your experience about solving production issues.

One of the most common question I have faced is talking about the last production problem you have faced and how did you solved it. If you are asked same question, give them step by step detail, right from analyzing problem to tactical fix to strategic solution.

In this article, I am going to share my list of Java Interview questions for Java guys having 2 to 5 years of experience. Since I had similar experience couple of year ago, I know what questions are asked and keeping a list for your own always helps when you start looking for new challenge in your career.

I am not providing answers of these question in this post due to two reasons, questions are quite simple and you guys probably know the answer, second providing answer means I cannot use this post for my own preparation later, which is more important.

Though, I could write another article answering all these question if anyone request or I feel people need it.

By the way, if you are new to Java programming language or want to improve Java skills then you can also checkout following best Java courses to get better:

  1. The Complete Java Masterclass (covers Java 17)
  2. Java Programming and Software Engineering Fundamentals Specialization Certificate on Coursera
  3. Java Programming Bootcamp: Zero to Mastery
  4. The Complete Java Programming Masterclass! [Karpado]
  5. CodeGym (learn Java by building Games)

These are my favorite online courses and platforms to learn Java from scratch and also build your Java skills. If you need more advanced courses to take your Java skill to next level you can also see following articles:

And, If you like my post, consider subscribing to my newsletter, its FREE and you will not miss any of my post

35 Java Interview Questions for 1 to 2 years Experienced

This list contains questions from different topics e.g. OOP concepts, multi-threading and concurrency, Java collections, Web services, Spring, Hibernate, Database and JDBC, it doesn’t cover all topics you need to prepare.

I will add few more topics later when I have some time, for now, try to answer these questions without doing Google :)

1. Java Interview questions on OOP Concepts

  1. What is difference between loose coupling and tight coupling?
  2. What is difference between cohesion and coupling?
  3. What is Liskov Substitution principle? Can you explain with example?
  4. What is difference between abstract class and interface in Java?
  5. What is difference between composition, aggregation and association?

2. Java Interview questions on Collections

  1. Difference between List, Set and Map in Java?
  2. Difference between synchronized and concurrent collection in Java?
  3. How get method of HashMap works in Java?
  4. How ConcurrentHashMap is different than Hashtable? How it achieve thread-safety?
  5. When to use LinkedList over ArrayList in Java?

3. Java Interview questions on Concurrency

  1. How notify and notifyAll work, and the difference between them. Why prefer notifyAll to notify?
  2. What is a race condition and how do you avoid it?
  3. What is a deadlock and how do you avoid it?
  4. What are some of the high-level concurrency classes provided by java.util.concurrent and how do they work?
  5. Can you implement producer consumer solution in Java?

4. Java Interview questions on Database

  1. How do you prevent SQL injection attacks?
  2. What is difference between WHERE and HAVING clause?
  3. What are transactions? What is ACID?
  4. Difference between truncate, delete and drop clause in SQL?
  5. What are window functions? how they work?

5. Java Interview questions on Hibernate

  1. When is it better to use plain SQL instead of ORM?
  2. Difference between sorted and ordered collection?
  3. How second level cache works?
  4. What is difference between save() and persist()?
  5. What is difference between Hibernate and MyBatis?

6. Java Interview questions on Web Services and Microservices

  1. What is the difference between SOAP-based web services and REST-based web services?
  2. What is SOAP Envelope?
  3. How to implement security in RESTful web service?
  4. What is Payload in REST?
  5. What is Microservices?
  6. What is difference between Microservices and REST?
  7. What is difference between Monolithic and Microservices?
    hint — development, one vs many, latency, deployment
  8. What problem does SAGA pattern solve?
    hint — distributed transactions
  9. What is service discovery in Microservices?
  10. What are common Microservices Pattern you have used in your project?

Java and Spring Interview Preparation Material

Before any Java and Spring Developer interview, I always use to read the below resources

Grokking the Java Interview: click here

I have personally bought these books to speed up my preparation.

You can get your sample copy here, check the content of it and go for it

Grokking the Java Interview [Free Sample Copy]: click here

If you want to prepare for the Spring Boot interview you follow this consolidated eBook, it also contains microservice questions from spring boot interviews.

Grokking the Spring Boot Interview

You can get your copy here — Grokking the Spring Boot Interview

Thank you guys for now. You can find the answers in web easily but if there are enough interest, I can also update the post. Let me know if you have also asked these questions before. If anyone knows answer, can also post as comment.

Good luck for your Java Interview.

By the way, if you are new to Java programming language or want to improve Java skills then you can also checkout following best Java courses to get better:

  1. The Complete Java Masterclass (covers Java 17)
  2. Java Programming and Software Engineering Fundamentals Specialization Certificate on Coursera
  3. Java Programming Bootcamp: Zero to Mastery
  4. The Complete Java Programming Masterclass! [Karpado]
  5. CodeGym (learn Java by building Games)

These are my favorite online courses and platforms to learn Java from scratch and also build your Java skills. If you need more advanced courses to take your Java skill to next level you can also see following articles:

Other Microservices and Java articles you may like

And, If you like my post, consider subscribing to my newsletter, its FREE and you will not miss any of my post

    Top 70 Java Interview Questions for Junior Developers [1 to 2 Years Experienced]

    Java Developer Interviews are very different than traditional software developer interviews. You can clear a Java interview without even writing a single line of code, Yes, this is true, you can become a Java developer without someone asking you to write a function in a Java interview. Though it's not the case everywhere and many companies are increasingly including a coding test in their Java developer interview process, but there are many companies and start-ups where you can get a Java job without writing a single line of code. All you need to do is learn those popular Java questions, which have been asked for ages, and mostly test whether a candidate is familiar with essential Java concepts or not like abstract class and interface. 

    Difference between save(), saveOrUpdate() and persist() in Hibernate Session

    The Session interface in Hibernate provides a couple of methods to move an object from a new or transient state to a persistent state like save(), saveOrUpdate(), and persist() is used to store an object into the database, but there are some significant differences between them. The Session.save() method does an INSERT to store the object into the database and it also returns the identifier generated by the database. On the other hand, saveOrUpdate() can be used to reattach a detached object in Hibernate Session i.e. it can do INSERT or UPDATE depending upon whether an object exists in the database or not. 

    15 Technical Core Java Interview Questions Answers for Experienced Developers

    When the experience of a Java Programmer grows in the years e.g. when it goes from beginner years ( 2 to 4) to more experience or sort of senior level ( 5 to 7 years), Core Java Interview Questions also change a bit. Of course, basics like data structure, algorithms, and object-oriented programming remains the same, but types of questions will become more advanced and their answers will definitely need to be more detailed and accurate. I often receive queries about core Java questions asked to a senior developer with 5 to 6-year experience, or, sometimes, I am going for an interview of a senior Java developer, what kind of questions I should expect. 

    Top 21 String Programming and Coding Interview Questions With Solutions

    In this article, I am going to share 21 of the most common String-based Programming and Coding interview questions from Java developer interviews. These questions require you to write code to solve the problem and they are different from traditional Java String questions like how the substring method works in Java? or when to use the intern() method of String in Java? Since coding and problem solving are an important part of any programming job interview, it's imperative that you know how to solve them in time and in a pressure situation, which comes only after doing practice with the right set of questions. Since these questions are already tried and tested and appeared in many interviews, they will provide you the experience you need to crack your coding interview.

    When You should Not use Microservice Architecture? (Answer)

     Hello guys, recently while giving interview in one of the big US based Investment bank I was asked about, what are the scenarios when you shouldn't be using Microservices architecture? When I hear this question I was big surprised not because I didn't know the answer but because most of the people ask about using Microservice architecture and this was the first time I am hearing otherwise. To be honest, it's a good question because most of the candidate will prepare about benefirst about Microservice architecture and they may not know when it's not appropriate to use it. Since I have worked in low latency high frequency application, I knew that multiple process means more latency so clearly a Microservices is a big no if you are working on a high frequency low latency application. In those cases you want to do all your calculations inside a single thread or process without even swapping memory to avoid delay. Hence the first answer to this question was, you shouldn't be using Microservice in a low latency application. 

    Difference between ReentrantLock vs synchronized lock in Java? Example Tutorial

    In concurrent programming, synchronization is essential to ensure that multiple threads can safely access shared resources without causing data inconsistencies or race conditions. In Java, there are two primary mechanisms for achieving synchronization: ReentrantLock and the synchronized keyword.  The ReentrantLock and synchronized lock both serve the purpose of allowing exclusive access to critical sections of code, but they differ in terms of flexibility, performance, and the level of control they provide to developers. Understanding the nuances between these two synchronization approaches is crucial for Java developers aiming to build efficient and reliable concurrent applications.

    13 Java Serialization Interview Questions with Answers for 3 to 5 Years Experienced

    There is no doubt that Java is vast and there are some Java topics which many Java developers rarely explore in work but they are important from a Java interview point of view. Serialization is one of them which is rarely used in practice but quite popular during Java interviews. It's also one of the difficult topics to master and that's why I am going to share some frequently asked Java Serialization interview questions in this article.  I don't know why people ask so many questions from Serialization if not everyone uses it but I have always seen some questions from Java realization. These are also the toughest and confusing questions to answer and more likely cannot be answered by an average Java developer.