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. 

This is great for candidates which are looking for their first job and doesn't have much real-world coding experience, but sometimes this style of the interview can cost you good developers who are not good at interviews. 

Someone, who knows how to structure a complex program, knows how to model their class and objects, can write good, robust code but fail to answer questions like, Why String is Immutable? or How HashMap works in Java?

Since I have gone through a lot of such interviews and even conducted a couple of them, I thought to compile a list of some of the most frequently asked Java interview questions, covering key topics like design patterns, design principles, OOP, JVM internals, Garbage collection, multithreading, generics and collections, XML parsing and others. 

This list is a collection of such questions. I have not answered them right here because I have already answered them in their individual post in this blog, you can visit the answer link to see the answer.

Btw, if you are new to Java then I highly recommend you to go through a comprehensive Java course like The Complete Java Master Class before attempting these questions. You will save a lot of time and will be better prepared for the interview. While you can learn a lot of useful Java concepts using these questions, it's still better to join a well-structured course. You can later revisit this list for quick revision. 




70+ Java Interview Questions with Answers Junior Developers

The sole purpose is to conduct mock Java interviews by yourself. You can use this list to do last-minute revisions. Since answers are not provided, you can try answering them and if you can then you are ready to take on any telephonic round of Java interview or face-to-face round which doesn't involve coding.

1) What is var in Java? can you use var in place of String? (answer)
2) can you override a final method in Java? (answer)
3) Can you override a private method in Java? (answer)
4) What is the difference between overloading, overriding, hiding, and shadowing? (answer)
5) Can you make an Abstract class final in Java? (answer)
6) Can you add an abstract method in a final class in Java? (answer)
7) Can you add a static or private method on an interface in Java? (answer)
8) Write wait-notify code for the producer-consumer problem? (solution)
9) Write code for thread-safe Singleton in Java? (answer)
10) What are 4 ways to iterate over Map in Java? Which one is best and why? (solution)
11) Write code to remove elements from ArrayList while iterating? (example)
12) is Swing thread-safe? (answer)
13) What is the thread-local variable in Java? (answer)
14) How do you convert a string to date in Java? (example)
15) Can we use String in the switch case? (Yes)
16) What is constructor chaining in Java? (answer)
17) Explain Java Heap space and Garbage collection? (answer)
18) Difference between major and minor GC? (answer)
19) Difference between -Xmx and -Xms JVM option? (answer)
20) How to check if a String contains only numeric digits? (regular expression)
21) Difference between poll() and remove() method of Queue in Java?
22) Difference between Comparator and Comparable in Java? (answer)
23) Why you need to override hashCode when you override equals in Java? (answer)
24) How HashSet works internally in Java? (answer)
25) How do you print Array in Java? (answer)
26) Explain what 'path to root' means in the context of garbage collection. What are roots?
27) write code for a simple implementation of HashMap/Hashtable
28) Write a short program to illustrate the concept of deadlock
29) Explain why recursive implementation of QuickSort will require O(log n) of additional space
30) Explain the design pattern used in Java stream/reader APIs.
31) Create an Iterator filtering framework: an IObjectTest interface with a single boolean test(Object method and an Iterator sub-class which is initialized with another Iterator and an IObjectTest instance. Your iterator will then allow iteration over the original, but skipping any objects which don't pass the test. Create a simple unit test for this framework.
32) Difference between Abstract class and Interface - given a situation what would you choose between abstract class and interface? (answer)
33) Difference between inheritance and composition? (answer)
34) Difference between ArrayList and linked list? (answer)
35) Difference between sleep and wait? (answer)
36) Explain about HashMap (methods in HashMap and  the project in which we have used the HashMap more about equals() and hashCode()  (answer)
37) Explain the methods in Object class? (answer)
38) What is coupling? How do you reduce coupling and why?
39) Struts config file - can there be multiple configs? (answer)
40) Design patterns - factory, abstract factory, singleton implemented? (answer)
41) What does static, final mean, purposes; (answer)
42) How many accessibility modifiers exist? Please describe them. (answer)
43) Why do you need a main method? (answer)
44) How many constructors can you have?
45) Define overwriting and overloading? (answer)
46) Give java API implementations for overwriting and overloading
47) Describe the String class – unique properties (answer)
48) StringBuilder vs StringBuffer? differences? (answer)
49) Collections: please describe, give some examples and compare them to each other
50) ArrayList vs Vector? Differences, when to use which data structure? (answer)
51) HashMap vs Hashtable (answer)
52) What’s a tree in Java? How different is the tree in data structure?
53) What’s a map? 
54) Multithreading: describe the thread management in Java?
55) What’s a semaphore? (answer)
56) How many states are there for threads?
57) Describe the usage of the synchronized word (2)? (examples)
58) Serialization in java – a description and usage? (example)
59) Garbage collection in java – description and usage
61) Can you guarantee the garbage collection process? No
62) Singleton, please describe the main features and coding (answer)
63) Factory. please describe the main features and coding (answer)
64) What is Dependency injection? What is the difference between Factory pattern and DI? (answer)
65) What is the difference between setter and constructor Injection? (answer)
66) What is a Composite design pattern?
67) Explain the Liskov substitution principle?
68) Write a Java program to convert bytes to long?
69) What is false sharing in multithreading Java?
70) Can we make an array volatile in Java? What is the effect of making it volatile? (answer)
71) What is advantage and disadvantage of busy spin waiting strategy? (answer)
72) A difference between DOM and SAX parser in Java? (answer)

These questions are good enough to revise many essential Java concepts but if you want more thorough Java interview preparation then you can also check out Ace the Java Interview track on Educative, a text-based, interactive learning platform, best for coding interviews. 



That's all about some common Java Programming concept-based Interview questions for beginners and junior developers with 1 to 2 years of experience. While this list is not comprehensive, it does touch on many important concepts which every Java programmer should know. By going through these interview questions and answers you can quickly revise those essential concepts and get ready for your telephonic or face-to-face interview. 


Other Java Interview Questions on different topics you may like to Explore
Thanks for reading this article so far. If you like these Java concepts interview questions for beginners then please share them with your friends and colleagues. If you have any questions or feedback then please drop a note. 

P. S. - If you can't answer these basic Java questions and you should join a comprehensive Java course to revise essential concepts. If you need a recommendation then I highly suggest going for The Complete Java Masterclass, an 80-hour long course on Udemy which you can buy for just $10 on Udemy sales. 

3 comments:

  1. To be honest, if you want to find good Java developers ask more tougher questoins like :
    How do you find memory leak in Java application?
    How do you find which par tof your application/object is consuming most of your heap?
    What is pros and cons of 32-bit vs 64-bit JVM?
    How do you remote debug Tomcat or your own Java application?
    How do you find CPU and Memory usage of your application?
    Which Operating sytsem you deploy your Java applicaiton? If Linux then ask about some useful commands which will help in debugging e.g. nestat, ps, find, lsof, top etc

    ReplyDelete
  2. Good questions, you can also check this huge list of Java interview questions for through preparation. It convers advanced topics like Concurrency, JVM internals, GC tuning, NIO and design patterns.

    ReplyDelete
  3. its really good set of IQs but for beginners. Please post some for 5yrs+ exp

    ReplyDelete

Feel free to comment, ask questions if you have any doubt.