Java Guide for Placements: Core Concepts, Collections and Interview Questions
Updated 28 Oct 2026 6 min read
On this page 14 sections
- 1Why Java still matters
- 2JDK, JRE and JVM
- 3Basics that get tested
- 4Object-oriented programming
- 5Strings
- 6The collections framework (the most important section)
- 7Exceptions
- 8Multithreading and concurrency
- 9Modern Java features (Java 8 and later)
- 10Generics and other topics
- 11Coding practice in Java
- 12How to answer Java questions well
- 13Common mistakes in interviews
- 14A 4-week plan
Why Java still matters
Java powers banking, insurance, e-commerce and large enterprise systems, and it is the main language taught in many colleges. Service companies and many product companies hire Java developers in large numbers (Spring Boot guide shows where it leads). Interviews test three things: core language concepts, collections and their internals, and your ability to write clean code (top Java questions gives short answers to the classics).
1. JDK, JRE and JVM
- JVM (Java Virtual Machine): runs bytecode and makes Java platform independent ("write once, run anywhere")
- JRE: the JVM plus the libraries needed to run programs
- JDK: the JRE plus tools to develop (compiler
javac, debugger and others)
Flow: .java source, compiled by javac into .class bytecode, executed by the JVM, which uses a JIT compiler to turn hot code into machine code. Know the three memory areas: heap (objects, shared, garbage collected), stack (method calls and local variables, per thread) and metaspace (class metadata). Garbage collection frees objects that are no longer reachable.
2. Basics that get tested
public class Hello {
public static void main(String[] args) {
int a = 10;
double d = 3.5;
boolean ok = true;
char c = 'A';
System.out.println("a = " + a);
}
}
- Primitives:
byte, short, int, long, float, double, char, boolean. Wrapper classes:Integer,Doubleand so on, with autoboxing and unboxing. - Integer cache trap:
Integer a = 127, b = 127; a == bis true, but with 1000 it is false because==compares references. Use.equals(). - Integer division and overflow:
5 / 2is 2, andInteger.MAX_VALUE + 1wraps to a negative number. staticmembers belong to the class,finalmeans a variable cannot be reassigned, a method cannot be overridden or a class cannot be extended.- Pass-by-value: Java always passes values; for objects, the value is a copy of the reference, so a method can change an object's content but cannot repoint the caller's variable.
3. Object-oriented programming
The four pillars, with Java meaning:
- Encapsulation: private fields with getters and setters
- Inheritance:
class Dog extends Animal; Java has single class inheritance - Polymorphism: compile-time (method overloading) and run-time (method overriding)
- Abstraction:
abstractclasses andinterfaces
abstract class Shape {
abstract double area();
}
class Circle extends Shape {
private final double r;
Circle(double r) { this.r = r; }
@Override double area() { return Math.PI * r * r; }
}
Shape s = new Circle(2); // run-time polymorphism
System.out.println(s.area());
Interview favourites: abstract class vs interface (state and constructors vs multiple inheritance of type, default methods since Java 8), overloading vs overriding, this vs super, constructors and constructor chaining, why Java has no multiple class inheritance (the diamond problem), and the SOLID principles (OOP guide).
4. Strings
String is immutable. Literals are stored in the string pool.
String a = "java";
String b = "java";
String c = new String("java");
System.out.println(a == b); // true (same pool object)
System.out.println(a == c); // false (different object)
System.out.println(a.equals(c)); // true
Use StringBuilder for repeated concatenation in loops (not thread-safe, fast) and StringBuffer when you need thread safety (synchronised, slower). Immutability gives thread safety, safe use as HashMap keys and security benefits.
5. The collections framework (the most important section)
Iterable -> Collection -> List (ArrayList, LinkedList, Vector)
-> Set (HashSet, LinkedHashSet, TreeSet)
-> Queue (PriorityQueue, ArrayDeque)
Map (HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap) -- separate hierarchy
| Choose | When |
|---|---|
ArrayList |
Fast random access; mostly reading and appending |
LinkedList |
Frequent insertion or removal at the ends |
HashSet / HashMap |
Fast lookup, no ordering needed |
LinkedHashMap |
Keep insertion order (also useful for an LRU cache) |
TreeMap / TreeSet |
Sorted order, O(log n) operations |
PriorityQueue |
Always get the smallest or largest element |
How HashMap works (asked in almost every Java interview):
- It computes
hashCode()of the key, then spreads it to pick a bucket in an array - Keys in the same bucket are kept in a linked list (converted to a balanced tree when a bucket grows large, since Java 8)
equals()is used to find the exact key in that bucket- When the number of entries exceeds
capacity × load factor(default 16 and 0.75), the table resizes (doubles) and entries are redistributed - Average
getandputare O(1); worst case is O(log n) with trees
The equals and hashCode contract: equal objects must have equal hash codes. If you override one, override the other, otherwise your objects behave strangely as keys.
Other questions: ArrayList vs LinkedList, HashMap vs Hashtable vs ConcurrentHashMap, HashSet internals (it is backed by a HashMap), fail-fast iterators (ConcurrentModificationException), Comparable vs Comparator, and Collections.sort vs Arrays.sort.
List<String> names = new ArrayList<>(List.of("Ravi", "Asha", "Kiran"));
names.sort(Comparator.comparing(String::length).thenComparing(Comparator.naturalOrder()));
6. Exceptions
- Checked exceptions (
IOException) must be handled or declared; unchecked (RuntimeException, such asNullPointerException) need not be Error(such asOutOfMemoryError) signals serious problems you normally do not catchtry,catch,finally; try-with-resources closes resources automatically
try (BufferedReader br = new BufferedReader(new FileReader("data.txt"))) {
System.out.println(br.readLine());
} catch (IOException e) {
System.err.println("Could not read file: " + e.getMessage());
}
Know throw vs throws, how to write a custom exception, and what happens when finally contains a return.
7. Multithreading and concurrency
ExecutorService pool = Executors.newFixedThreadPool(4);
Future<Integer> result = pool.submit(() -> 21 * 2);
System.out.println(result.get()); // 42
pool.shutdown();
- Create threads by extending
Thread, implementingRunnable, or (preferably) using an executor service - Thread states: new, runnable, blocked, waiting, timed waiting, terminated
- Race condition, synchronized blocks, volatile (visibility, not atomicity), atomic classes and locks
wait/notifyvssleep, deadlock (and how to avoid it), thread pools,ConcurrentHashMap,CompletableFuture
Understand the problem each tool solves, not only the names (operating systems guide explains deadlocks and synchronisation in general).
8. Modern Java features (Java 8 and later)
List<String> names = List.of("Asha", "Ravi", "Kiran", "Anu");
List<String> result = names.stream()
.filter(n -> n.startsWith("A"))
.map(String::toUpperCase)
.sorted()
.toList(); // [ANU, ASHA]
Optional<String> first = names.stream().findFirst();
System.out.println(first.orElse("none"));
- Lambdas and functional interfaces (
Predicate,Function,Consumer,Supplier) - Streams:
filter,map,collect,reduce,groupingBy; intermediate vs terminal operations; lazy evaluation Optionalto avoid null checks; default methods in interfaces- Newer additions you may mention if you have used them:
var, records, text blocks, switch expressions, sealed classes
9. Generics and other topics
Generics give compile-time type safety (List<String>); know type erasure at run time, wildcards (? extends, ? super) at a basic level. Also revise: inner and anonymous classes, enums, the Object class methods (equals, hashCode, toString), serialization at a basic level, and the final, finally and finalize difference.
10. Coding practice in Java
// Reverse words in a sentence
static String reverseWords(String s) {
String[] parts = s.trim().split("\\s+");
StringBuilder sb = new StringBuilder();
for (int i = parts.length - 1; i >= 0; i--) {
sb.append(parts[i]);
if (i > 0) sb.append(' ');
}
return sb.toString();
}
// Frequency of characters
static Map<Character, Integer> freq(String s) {
Map<Character, Integer> m = new HashMap<>();
for (char c : s.toCharArray()) m.merge(c, 1, Integer::sum);
return m;
}
Programs asked again and again: palindrome, Fibonacci, prime check, factorial, anagram check, reverse a string or linked list, find duplicates, second largest element, matrix operations and a simple singleton class. Write them without an IDE, and get comfortable reading input, using Scanner or BufferedReader (DSA plan).
11. How to answer Java questions well
- Define the concept in one sentence
- Explain why it exists or what problem it solves
- Show a tiny example or a comparison
- Mention a trade-off or a pitfall
Example: asked "Why is String immutable?", say: it makes strings safe to share between threads, safe as hash keys, enables the string pool to save memory, and protects values like file paths and class names from being changed after validation. The cost is extra objects when concatenating in loops, which is why StringBuilder exists.
12. Common mistakes in interviews
- Memorising definitions without being able to write the code
- Using
==to compare strings or boxed integers - Not knowing how
HashMapworks internally - Ignoring null checks and edge cases
- Claiming experience in a feature you cannot explain; interviewers will ask follow-ups
13. A 4-week plan
- Week 1: syntax, OOP, strings; write 25 basic programs
- Week 2: collections and exceptions; implement a small library or inventory app
- Week 3: multithreading, Java 8 streams, generics; revise from the questions above
- Week 4: SQL and JDBC basics, a small Spring Boot REST project and mock interviews (SQL guide)
Finish with the technical interview checklist.
Found this useful? Share it with a friend.