☕ Java Development
Java interviews for fresher and 0-2 year roles lean heavily on fundamentals: OOP, collections, exceptions, and the few multithreading and JVM basics that come up again and again. This track covers 14 of the most common questions in depth — enough to walk in prepared, not just familiar.
Download the free PDF
Same 14 questions as below, plus 2 DSA mock problems and the 60-minute mock structure — typeset to actually study from, offline or on your phone.
Common interview questions
Not exact questions you'll be asked — but the shape of what gets asked, and how a strong answer is structured.
What is the difference between JDK, JRE, and JVM?
The JVM runs bytecode, is platform-specific, and handles memory and garbage collection. The JRE is the JVM plus the core libraries needed to run Java programs. The JDK is the JRE plus development tools like the compiler (javac) and debugger, needed to write and build programs. So JDK contains JRE, which contains JVM — and 'write once, run anywhere' works because javac produces platform-independent bytecode while each OS has its own JVM to run it.
Why is Java platform independent?
Source code compiles to bytecode, not machine code, and any machine with a JVM can run that bytecode. It's the JVM that's platform-specific, not your compiled code — each OS needs its own JVM implementation, but the .class file you ship is the same everywhere.
Explain the four pillars of OOP with a Java example.
Using a payment system as the example: encapsulation keeps a field private with validated getters/setters; inheritance lets a subclass like CreditCardPayment extend a shared Payment base; polymorphism means calling process() on a Payment reference runs whichever subclass's version actually got created; abstraction means an abstract Payment class declares what must be done without callers seeing how.
abstract class Payment {
abstract void process();
}
class UpiPayment extends Payment {
@Override void process() { /* ... */ }
}
Payment p = new UpiPayment();
p.process(); // resolved at runtime — polymorphismMethod overloading vs overriding?
Overloading happens within the same class — same method name, different parameters, resolved at compile time, and the return type can differ. Overriding happens between a parent and child class — same signature, resolved at runtime, and the return type must be the same or covariant. You cannot override a static, final, or private method.
class Calc {
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; } // overload
}
class Dog extends Animal {
@Override void sound() { System.out.println("Woof"); } // override
}Abstract class vs interface?
A class can extend only one abstract class but implement many interfaces. An abstract class can hold instance fields and a mix of abstract and concrete methods; an interface traditionally held only constants, though Java 8+ added default and static methods. Abstract classes can have constructors, interfaces can't. Reach for an abstract class for shared base code ('is-a'), an interface for a capability contract ('can-do').
Why is String immutable in Java?
Four reasons: security, since strings often hold things like file paths or usernames that shouldn't mutate after validation; the string pool, which can only safely share literals if nothing can change them; thread safety, since immutable objects never need synchronization; and hash caching, since hashCode() can be computed once and reused, which is why strings make good HashMap keys.
String vs StringBuilder vs StringBuffer?
String is immutable and thread-safe by nature, but slow for repeated edits since every change creates a new object. StringBuilder is mutable and the fastest option, but not thread-safe. StringBuffer is mutable and thread-safe (synchronized), but slower than StringBuilder as a result. Default to StringBuilder for building strings in a loop, and only reach for StringBuffer if multiple threads genuinely share it.
Checked vs unchecked exceptions?
Checked exceptions are verified at compile time — you must handle or declare them — and extend Exception without extending RuntimeException; IOException and SQLException are typical examples. Unchecked exceptions extend RuntimeException and aren't enforced by the compiler, like NullPointerException or ArrayIndexOutOfBoundsException. Errors like OutOfMemoryError are serious JVM-level problems you generally don't try to catch.
ArrayList vs LinkedList?
ArrayList is backed by a dynamic array: O(1) get by index, O(1) amortized add at the end, but O(n) insert/remove in the middle due to shifting. LinkedList is a doubly linked list: O(n) get by index, O(1) add/remove at the ends, and O(1) insert/remove once you've found the node — but finding it is still O(n). In practice, default to ArrayList; it usually wins even for middle inserts because of cache-friendly memory layout.
How does HashMap work internally?
key.hashCode() is computed and spread to pick a bucket index. An empty bucket stores the entry directly; a collision compares keys with equals() — a match replaces the value, otherwise the entry joins that bucket's chain. Since Java 8, a long chain (8+ entries, with a large enough table) converts to a balanced tree, improving worst-case lookup from O(n) to O(log n). When size exceeds capacity times the load factor (default 0.75), the table resizes and redistributes entries. Average get/put is O(1) — and you must override hashCode() whenever you override equals(), or equal objects can land in different buckets and the map simply won't find them.
Two ways to create a thread? Which is better?
Extend Thread and override run(), or implement Runnable and pass it to a Thread. Runnable is generally preferred: Java has single inheritance, so extending Thread uses up your one chance, and Runnable cleanly separates the task from the threading mechanism. In real projects, an ExecutorService is better than creating threads manually either way. One common trap: calling start() creates a new thread, while calling run() directly just runs it like a normal method on the current thread.
What are lambda expressions and functional interfaces?
A functional interface has exactly one abstract method — Runnable, Comparator, and Function are common examples. A lambda is a short way to implement one inline, without a named class. The most-used built-ins are Predicate<T> for a boolean test, Function<T,R> for a transform, Consumer<T> for using a value, and Supplier<T> for providing one.
Runnable r = () -> System.out.println("hello");
Comparator<Integer> c = (a, b) -> b - a;What is the Stream API? Give an example.
Streams process collections declaratively, in three stages: a source, lazy intermediate operations, and one terminal operation that actually triggers execution. They read like a pipeline and avoid writing explicit loops for common filter/transform/collect work.
List<String> result = names.stream()
.filter(n -> n.startsWith("A"))
.map(String::toUpperCase)
.sorted()
.collect(Collectors.toList());Stack vs heap memory?
The stack holds method call frames, local variables, and object references — it's per-thread, fast, and automatically cleaned up when a method returns. The heap holds the actual objects and is shared across all threads, managed by the garbage collector. A StackOverflowError happens when the stack fills up (usually deep or infinite recursion); an OutOfMemoryError happens when the heap fills up.
Your learning path
In order — each step builds on the last.
- 01
Core Java & OOP, cold
Work through JDK/JRE/JVM, the four OOP pillars, and overloading vs overriding until you can explain each without rereading your own notes.
- 02
Strings, exceptions, collections
String immutability, checked vs unchecked exceptions, and ArrayList/HashMap internals — the section most fresher interviews spend the most time on.
- 03
Threads, Java 8+, and the JVM
Just enough multithreading to not freeze up, plus lambdas, streams, and the stack/heap split — this is usually a smaller slice of the interview, not the whole thing.
- 04
Run it like a real interview
Use the 60-minute mock structure (intro, DSA, fundamentals, project, close) at least twice before the real thing.
4-week study roadmap
A week-by-week plan, not just a topic list. Check items off as you go — your progress is saved on this device.
Core Java & OOP foundations
Strings, exceptions & collections
Multithreading, Java 8+ & JVM
Mock interviews
Before you walk in: field checklist
The field-specific things worth double-checking you've covered.
Interview-day checklist
The same basics matter whatever role you're interviewing for.
Free resources to study from
Oracle Java Documentation ↗
The official spec — good for settling any 'but what does it actually say' question
Baeldung ↗
Free, detailed write-ups on nearly every Core Java and Collections topic
GeeksforGeeks — Java ↗
Free practice questions and explanations by topic
LeetCode ↗
For the DSA side of the interview, filterable by language and topic
Prep Trek Premium: Java Black Belt
This free track covers 14 of the 44 questions in the full Java Interview Q&A Bank, 2 of the 6 DSA mock problems, and none of the visual Java Black Belt notes. Premium picks up exactly where this leaves off.
- ✓30 more Q&A answers: == vs .equals(), static/final, access modifiers, wrapper classes, the full Collections set (HashMap vs ConcurrentHashMap, TreeSet, Comparable vs Comparator, fail-fast iterators), multithreading (synchronization, volatile, deadlock, thread pools), Java 8+ (Optional, map vs flatMap), and JVM internals & garbage collection
- ✓The output-prediction drill — the 'what does this print?' trap questions interviewers love
- ✓4 more DSA mock problems (linked lists, cycle detection, tree traversal, binary search traps) with graded hints
- ✓13 more CS fundamentals answers across OOP, DBMS, Operating Systems and Computer Networks
- ✓The project deep-dive question bank plus a fill-in answer template
- ✓12 behavioral questions to rehearse, an interviewer scorecard, a peer-mock script, and a full 4-week mock schedule
- ✓Java Black Belt visual notes — Core Java, Collections, and Threads, plus a traps quiz with an answer key
Cold mail tips for this field
- —Lead with one specific thing about their engineering work, not 'I'm very interested in your company.'
- —Link a project, not just a resume attachment — something they can open in one click.
- —Keep it under 150 words. A long cold email reads as unconfident.
Ready to put this to use?
Browse open roles →