35 Java Interview Questions for 1 to 3 Years Experienced Developers
Here are 35 most popular Java interview questions for senior developers with 1 to 3 years of experience in core Java.
Preparing for a Java developer interview? Here is a list of some useful Java interview questions for experienced Java programmers with 2 to 5 years of experience.
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 applications, Algorithm and Data structure, Some questions on design patterns, JVM and Garbage collection, and a couple of puzzles.
Actually, it’s a mix of everything you do in your day-to-day work.
If you are going for a Java developer with some exposure to 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 with solving production issues.
One of the most common questions I have faced is talking about the last production problem you have faced and how you solved it. If you are asked the same question, give them step-by-step details, right from analyzing the problem to the tactical fix to the 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 a similar experience a couple of years ago, I know what questions are asked, and keeping a list for your own always helps when you start looking for a new challenge in your career.
I am not providing answers to these questions in this post for two reasons: the questions are quite simple, and you guys probably know the answer. Second, providing answers means I cannot use this post for my own preparation later, which is more important.
Though I could write another article answering all these questions if anyone requests, or if I feel people need it.
By the way, if you are new to the Java programming language or want to improve your Java skills, then you can also check out the following best Java courses to get better:
Java Programming and Software Engineering Fundamentals Specialization Certificate on Coursera
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.
Java Interview Questions for 1 to 3 years of Experience
This list contains questions from different topics like OOP concepts, multi-threading and concurrency, Java collections, Web services, Spring, Hibernate, Database, and JDBC; it doesn’t cover all the topics you need to prepare.
I will add a 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
What is the difference between loose coupling and tight coupling?
What is the difference between cohesion and coupling?
What is the Liskov Substitution principle? Can you explain with an example?
What is the difference between an abstract class and an interface in Java?
What is the difference between composition, aggregation, and association?
2. Java Interview Questions on Collections
Difference between List, Set, and Map in Java?
Difference between synchronized and concurrent collections in Java?
How get method of HashMap work in Java?
How is ConcurrentHashMap different than Hashtable? How does it achieve thread-safety?
When to use LinkedList over ArrayList in Java?
3. Java Interview Questions on Concurrency
How notify and notifyAll work, and the difference between them. Why prefer notifyAll to notify?
What is a race condition, and how do you avoid it?
What is a deadlock, and how do you avoid it?
What are some of the high-level concurrency classes provided by java.util.concurrent, and how do they work?
Can you implement producer producer-consumer solution in Java?
4. Java Interview Questions on Database
How do you prevent SQL injection attacks?
What is the difference between WHERE and HAVING clauses?
What are transactions? What is ACID?
Difference between the truncate, delete, and drop clauses in SQL?
What are window functions? How do they work?
5. Java Interview Questions on Hibernate
When is it better to use plain SQL instead of ORM?
Difference between sorted and ordered collections?
How does the second-level cache work?
What is the difference between save() and persist()?
What is the difference between Hibernate and MyBatis?
6. Java Interview Questions on Web Services and Microservices
What is the difference between SOAP-based web services and REST-based web services?
What is SOAP Envelope?
How to implement security in a RESTful web service?
What is Payload in REST?
What are Microservices?
What is the difference between Microservices and REST?
What is the difference between Monolithic and Microservices?
Hint — development, one vs many, latency, deploymentWhat problem does the SAGA pattern solve?
Hint — distributed transactionsWhat is service discovery in Microservices?
What are the common Microservices Patterns you have used in your project?
Java and Spring Interview Preparation Material
Before any Java and Spring Developer interview, I always used to read the following 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 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 on the web easily, but if there is enough interest, I can also update the post. Let me know if you have also asked these questions before. If anyone knows the answer, they can also post as a comment.
Good luck with your Java Interview.
By the way, if you are new to the Java programming language or want to improve your Java skills, then you can also check out the following best Java courses to get better:
Java Programming and Software Engineering Fundamentals Specialization Certificate on Coursera
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.
Other articles you may like to read