Blog/Java Interview Questions for Freshers: 25 Questions With Answers

Java Interview Questions for Freshers: 25 Questions With Answers

25 fresher-level Java interview questions with complete answers and code, a topic-weighting table and a 7-day revision plan.

Last updated: 13 October 2026 · By the Asuraa Team

Quick answer: The Java interview questions freshers face most cover JDK vs JVM, == vs equals, String immutability, OOP (abstract class vs interface, overloading vs overriding), HashMap internals, checked vs unchecked exceptions and Java 8 streams. Know current versions too: Oracle's support roadmap lists Java 21 (September 2023) and Java 25 (September 2025) as LTS releases. Answer each question with a definition, a reason and a short example.

Key takeaways

  • Fresher Java interviews concentrate on language basics, OOP, collections, exceptions and Java 8+ features, with one or two multithreading questions.
  • Oracle's HashMap documentation gives a default initial capacity of 16 and a default load factor of 0.75, and says get and put are constant time only when the hash function spreads keys well.
  • Oracle's Java SE support roadmap lists Java 8, 11, 17, 21 and 25 as LTS releases, with Java 21 released in September 2023 and Java 25 in September 2025.
  • Records became a permanent Java feature in JDK 16 through JEP 395, and the compiler generates their fields, accessors, constructor, equals, hashCode and toString.
  • Asuraa's October 2026 job market report found Java named in 18.7% of the fresher listings it analysed.

Java interviews for freshers in India stay close to five areas: language basics, OOP in Java, collections, exceptions, and Java 8+ features, with a little multithreading. The 25 questions below are grouped by those areas, and every answer is written so you can say it aloud in about a minute. Java also shows up in real job listings: Asuraa's October 2026 job market report found Java named in 18.7% of the fresher listings it analysed.

Which Java topics carry the most weight in a fresher interview?

Core language basics and OOP carry the most weight, followed closely by collections. The table shows where questions usually come from and what the interviewer is really testing.

AreaTypical questionsWhat interviewers check
Language basicsJDK vs JVM, == vs equals, String immutabilityWhether you understand how Java runs, not just syntax
OOP in JavaAbstract class vs interface, overloading vs overridingDesign reasoning with a small example
CollectionsHashMap internals, ArrayList vs LinkedListChoosing the right structure and its cost
ExceptionsChecked vs unchecked, finally, try-with-resourcesSafe error handling and resource cleanup
Java 8+Lambdas, streams, records, LTS versionsWhether your Java is current
MultithreadingThread vs Runnable, synchronizedAwareness of shared-state bugs

For a cross-subject view of what to prepare, see the interview questions by subject guide.

What are the core Java basics questions for freshers?

These seven questions test whether you know what happens between writing code and running it.

1. What is the difference between JDK, JRE and JVM?

The JVM (Java Virtual Machine) executes bytecode and handles memory management and garbage collection. The JRE (Java Runtime Environment) is the JVM plus the standard class libraries needed to run a program. The JDK (Java Development Kit) is the JRE plus development tools such as the javac compiler, jar and the debugger. As a developer you install the JDK, which includes everything needed to both compile and run programs.

2. Why is Java called platform independent?

The compiler turns .java source into .class bytecode, not machine code for one processor. Any machine with a compatible JVM can run that bytecode, so the same compiled program runs on Windows, Linux or macOS. The JVM itself is platform specific; the bytecode is not. This is the "write once, run anywhere" idea.

3. What is the difference between == and equals()?

== compares references for objects (are these the same object in memory?) and values for primitives. equals() compares logical content when a class overrides it, as String does. If you override equals(), you must also override hashCode() so equal objects land in the same hash bucket.

String a = new String("asuraa");
String b = new String("asuraa");
System.out.println(a == b);      // false: two objects
System.out.println(a.equals(b)); // true: same characters

4. Why is String immutable in Java?

Once a String is created, its value cannot change; methods like toUpperCase() return a new object. The official String documentation states that strings are constant and, because they are immutable, they can be shared. Immutability makes strings safe to use as HashMap keys, safe to share between threads, and allows string literals to be reused instead of copied.

5. What is the difference between String, StringBuilder and StringBuffer?

String is immutable, so repeated concatenation in a loop creates many temporary objects. StringBuilder is mutable and not synchronized, which makes it the right choice for building strings in a single thread. StringBuffer is also mutable but its methods are synchronized, so it is slower and only useful when several threads share one buffer. In interviews, say you use StringBuilder by default inside loops.

6. What are wrapper classes and autoboxing?

Each primitive (int, double, char, boolean and so on) has a wrapper class (Integer, Double, Character, Boolean). Collections can only hold objects, so List needs wrappers. Autoboxing is the automatic conversion from int to Integer, and unboxing is the reverse. Watch for NullPointerException when unboxing a null Integer.

7. What is the difference between final, finally and finalize?

final is a keyword: a final variable cannot be reassigned, a final method cannot be overridden, and a final class cannot be extended. finally is a block that runs after try/catch whether or not an exception occurred, used for cleanup. finalize() was a method the garbage collector could call before reclaiming an object; it is deprecated and you should not rely on it. Use try-with-resources for cleanup instead.

What OOP questions are asked in Java interviews?

Expect at least two of these in every technical round, usually with "give an example". For the language-neutral version of these concepts, see OOPs interview questions for freshers.

8. Why does Java not support multiple inheritance of classes?

A class can extend only one class because inheriting fields from several parents creates ambiguity about which constructor or method initialises shared state. Oracle's tutorial on multiple inheritance explains that Java allows multiple inheritance of type through interfaces instead. Since Java 8, interfaces can carry default methods; if two interfaces give the same default method, the implementing class must override it and can pick one with A.super.hello().

9. What is the difference between an abstract class and an interface?

An abstract class can have instance fields, constructors, concrete methods and any access modifier; a class can extend only one. An interface defines a contract; its fields are always public static final, and a class can implement many interfaces. Oracle's abstract classes page suggests an abstract class when closely related classes share code and state, and an interface when unrelated classes share a behaviour, such as Comparable.

10. What is the difference between method overloading and overriding?

Overloading means same method name, different parameter lists, in the same class; it is resolved at compile time. Overriding means a subclass provides its own version of an inherited instance method with the same signature; the call is resolved at runtime based on the object's actual type. An overriding method can widen access (protected to public) but not narrow it, and may return a subtype of the original return type, per Oracle's overriding tutorial.

11. What does the static keyword mean?

A static field or method belongs to the class, not to any object, so all instances share one copy. You call static methods with the class name, such as Math.max(a, b). A static method cannot use this or access instance fields directly. Static methods are hidden, not overridden, when a subclass declares the same signature.

12. What is a constructor, and how do this() and super() work?

A constructor initialises a new object; it has the class name and no return type. If you write none, the compiler adds a no-argument default constructor. this(...) calls another constructor in the same class, and super(...) calls the parent constructor; either must be the first statement. Constructors are not inherited and cannot be overridden.

13. What are the access modifiers in Java?

private is visible only inside the class, default (no keyword) inside the same package, protected inside the package plus subclasses, and public everywhere. Good encapsulation keeps fields private and exposes behaviour through methods. Interviewers like it when you explain why: it lets you change internals without breaking callers.

Which Java collections questions come up most?

Collections questions test whether you pick the right structure and know its cost.

14. What is the difference between ArrayList and LinkedList?

ArrayList is backed by a resizable array, so get(i) is constant time but inserting in the middle shifts elements. LinkedList is a doubly linked list, so inserting or removing at a known node is cheap but get(i) walks the list. In practice ArrayList is the default because it is cache friendly; choose LinkedList (or better, ArrayDeque) only for queue-like use.

15. How does HashMap work internally?

HashMap stores entries in an array of buckets; the key's hashCode() decides the bucket and equals() finds the exact key inside it. The HashMap documentation gives a default initial capacity of 16 and a default load factor of 0.75; when entries exceed capacity times load factor, the table is rehashed to roughly twice the buckets. get and put are constant time on average if the hash function spreads keys well. It permits one null key and null values, and it is not synchronized.

16. What is the difference between HashMap, Hashtable and ConcurrentHashMap?

HashMap is unsynchronized and allows nulls; the official docs describe it as roughly equivalent to Hashtable except for those two points. Hashtable is a legacy class whose methods are synchronized, which makes it slow under contention. ConcurrentHashMap is the modern thread-safe choice: it allows concurrent reads and fine-grained updates and does not allow null keys or values.

17. What is the difference between Comparable and Comparator?

Comparable defines a class's natural order through compareTo() inside the class itself, such as alphabetical order for String. Comparator is a separate object that defines an alternative order, so you can sort the same objects in many ways without changing the class.

students.sort(Comparator.comparing(Student::marks).reversed());

18. What is a fail-fast iterator?

Iterators of ArrayList and HashMap throw ConcurrentModificationException if the collection is structurally modified during iteration by anything other than the iterator itself. It is a bug detector, not a guarantee. To remove while iterating, use iterator.remove() or list.removeIf(x -> x < 0).

What exception-handling questions should freshers prepare?

Two or three exception questions are common, often tied to a code snippet.

19. What is the difference between checked and unchecked exceptions?

Checked exceptions (subclasses of Exception but not RuntimeException, such as IOException) must be caught or declared with throws, and the compiler enforces it. Unchecked exceptions (RuntimeException subclasses such as NullPointerException and ArrayIndexOutOfBoundsException) usually signal programming errors and need no declaration. Error types like OutOfMemoryError are serious problems an application should not try to recover from.

20. What is the difference between throw and throws, and what is try-with-resources?

throw actually throws one exception object inside a method; throws in a method signature declares which checked exceptions the method may pass to its caller. Try-with-resources closes any AutoCloseable resource automatically, even if an exception occurs, which replaces most finally cleanup code.

try (BufferedReader br = new BufferedReader(new FileReader("data.txt"))) {
    System.out.println(br.readLine());
}

Which Java 8+ and modern Java questions are asked?

Interviewers use these to check that your Java is not stuck in an old textbook.

21. What is a lambda expression and a functional interface?

A functional interface has exactly one abstract method, such as Runnable, Comparator or Predicate. A lambda is a short way to supply that method's implementation without an anonymous class. (a, b) -> a + b is a lambda; @FunctionalInterface asks the compiler to verify there is only one abstract method.

22. What is the Stream API? Give an example.

A stream processes a sequence of elements through a pipeline of intermediate operations (filter, map, sorted) and one terminal operation (collect, count, forEach). Streams are lazy: nothing runs until the terminal operation. They do not modify the source collection.

List names = students.stream()
    .filter(s -> s.marks() >= 60)
    .map(Student::name)
    .toList();

23. What is a record in Java?

A record is a concise class for immutable data carriers, declared as record Point(int x, int y) {}. Per Oracle's records documentation, the compiler generates private final fields, accessor methods, a canonical constructor, and equals, hashCode and toString; records are implicitly final. Records became a permanent feature in JDK 16 through JEP 395. They are ideal for DTOs and API responses.

24. Which Java version should a fresher know, and what is LTS?

LTS (long-term support) releases get years of updates, so companies standardise on them. Oracle's Java SE support roadmap lists Java SE 8, 11, 17, 21 and 25 as LTS releases, with Java 21 released in September 2023 and Java 25 in September 2025. Many existing company codebases still run older LTS versions such as Java 8, 11 or 17, so know lambdas and streams (Java 8) and be able to name a few newer features such as records and var.

What multithreading basics do freshers need?

One threading question is common; deep concurrency is rare at fresher level.

25. How do you create a thread, and what does synchronized do?

You can extend Thread or, preferably, implement Runnable (or Callable) and hand it to a Thread or an ExecutorService, which keeps your class free to extend something else. synchronized on a method or block lets only one thread hold the object's lock at a time, preventing two threads from corrupting shared state. Mention that overusing it causes contention, and that java.util.concurrent classes like AtomicInteger and ConcurrentHashMap are usually better.

How should you revise Java in 7 days before the interview?

Revise one area per day, write code by hand for each answer, and finish with a mock round. The technical interview preparation guide covers how to structure answers aloud.

  1. Day 1: Basics. JDK/JRE/JVM, data types, String, == vs equals. Write the String comparison snippet from memory.
  2. Day 2: OOP. Four pillars with one example each, abstract class vs interface, overloading vs overriding.
  3. Day 3: Collections. List, Set, Map hierarchy; HashMap internals; sort a list with a Comparator.
  4. Day 4: Exceptions and keywords. Checked vs unchecked, try-with-resources, static, final.
  5. Day 5: Java 8+. Write five stream pipelines (filter, map, group, count, sort) and one record.
  6. Day 6: Coding. Solve eight easy array and string problems in Java: reverse a string, find duplicates, count frequency with a HashMap.
  7. Day 7: Mock and projects. Do a 30-minute mock interview, then prepare a two-minute explanation of every Java project on your resume.

If you are still building fundamentals, start with how to learn Java for jobs before using this list.

What do most guides on Java interview questions get wrong?

Most guides treat Java interviews as definition recall, but freshers are usually rejected for not being able to apply the definition. Saying "HashMap is O(1)" is incomplete; the documented condition is that the hash function spreads keys well, and a bad hashCode() degrades performance. Many lists also still teach finalize(), Vector and Hashtable as if they were normal choices, when modern code avoids them. Finally, guides often skip "why did you use Java in your project?", which is asked constantly. Prepare a concrete answer tied to your own project, not a definition.

Related guides

FAQ

What are the most common Java interview questions for freshers?

The most common are JDK vs JRE vs JVM, == vs equals(), why String is immutable, String vs StringBuilder, abstract class vs interface, overloading vs overriding, how HashMap works, checked vs unchecked exceptions, and a Java 8 stream example. Prepare each with a one-line definition, the reason it matters and a short code example you can write on paper.

Which Java version should I learn for interviews in 2026?

Learn on a current LTS release such as Java 21 or Java 25, both listed as LTS on Oracle's Java SE support roadmap. Many company projects still run Java 8, 11 or 17, so be comfortable with Java 8 lambdas and streams and be able to name newer features such as records and var.

How do I explain HashMap internal working in an interview?

Say that HashMap keeps an array of buckets, uses the key's hashCode() to pick a bucket and equals() to find the exact key. Oracle's docs give a default capacity of 16 and load factor of 0.75, after which the table is rehashed to about twice the buckets. get and put are constant time on average if keys hash well.

Are Java coding questions asked in fresher interviews?

Yes. Most technical rounds include at least one small coding task in Java, such as reversing a string, finding duplicates in an array, counting character frequency with a HashMap or sorting objects with a Comparator. Practise writing these without an IDE, because some interviews use paper or a plain online editor.

How long does it take to prepare Java for a fresher interview?

If you already know Java from college, a focused 7-day revision covering basics, OOP, collections, exceptions, Java 8 features, coding practice and a mock round is usually enough to answer standard questions. If you are new to Java, spend several weeks learning and building one small project first, then use the 7-day plan.

Final thoughts

Java interviews reward freshers who can explain why, not just what: why String is immutable, why HashMap needs a good hashCode(), why you chose an interface. Practise saying each answer aloud with a small example, then tie it to your own project. When you are ready to apply, filter Java roles on Asuraa jobs and check your resume against the job description with the AI resume reviewer.

Related articles

Share this article

Continue Reading

Data Science Career Paths

Explore different career trajectories in data science and find your perfect fit.

Read article →

Building Your DS Portfolio

Learn how to create projects that impress hiring managers and showcase your skills.

Read article →

Salary Negotiation Guide

Get the compensation you deserve with our proven negotiation strategies.

Review Your Resume →