Java Interview Notes - From Scratch to
Advanced
1. Introduction to Java
Java is a high-level, object-oriented programming language developed by Sun
Microsystems (now Oracle).
Platform Independent: 'Write once, run anywhere' using JVM.
Strongly typed, compiled and interpreted.
Used for web apps, mobile apps (Android), enterprise apps, and more.
2. Java Basics
Data Types: byte, short, int, long, float, double, char, boolean.
Variables: Local, Instance, Static.
Operators: Arithmetic, Relational, Logical, Bitwise, Assignment, Ternary.
Control Statements: if-else, switch, for, while, do-while, break, continue.
3. OOP Concepts
Class and Object.
Encapsulation: Using private fields + public getters/setters.
Inheritance: Single, Multilevel, Hierarchical (No Multiple Inheritance via classes).
Polymorphism: Compile-time (method overloading), Runtime (method overriding).
Abstraction: Abstract classes, Interfaces.
Constructor: Default, Parameterized, Copy.
4. Strings
Immutable in Java.
String, StringBuilder (mutable), StringBuffer (mutable, thread-safe).
Important methods: length(), substring(), equals(), compareTo(), split(), replace(),
indexOf(), toLowerCase(), toUpperCase().
5. Arrays
Single Dimensional and Multi Dimensional arrays.
Methods in Arrays class: sort(), binarySearch(), fill(), copyOf().
Enhanced for loop for traversal.
6. Collections Framework
List: ArrayList, LinkedList, Vector.
Set: HashSet, LinkedHashSet, TreeSet.
Map: HashMap, LinkedHashMap, TreeMap, Hashtable.
Queue: PriorityQueue, LinkedList.
Important interfaces: Collection, List, Set, Map, Queue.
Utility class: Collections (sort, reverse, shuffle, etc.).
7. Exception Handling
Checked vs Unchecked exceptions.
try-catch-finally, throw, throws.
Custom exceptions.
Common exceptions: NullPointerException, ArrayIndexOutOfBoundsException,
IOException.
8. Multithreading
Thread class, Runnable interface.
Thread lifecycle: New, Runnable, Running, Waiting, Terminated.
Synchronization, volatile keyword.
Executor framework.
9. Java Memory Management
Stack vs Heap.
Garbage Collection: finalize(), System.gc().
Memory leaks and prevention.
10. Java 8+ Features
Lambda Expressions.
Functional Interfaces (@FunctionalInterface).
Streams API.
Default and Static methods in interfaces.
Optional class.
Method references.
11. File Handling
File, FileReader, FileWriter, BufferedReader, BufferedWriter.
Serialization and Deserialization.
NIO package.
12. Important Keywords
static, final, this, super, transient, volatile, synchronized.
break, continue, return.
13. Design Patterns in Java
Singleton, Factory, Builder, Observer, Strategy.
14. Common Interview Programs
Reverse a string, Palindrome check, Fibonacci series.
Prime number check, Factorial calculation.
Sorting algorithms: Bubble, Selection, Insertion, Merge, Quick.
Collections sorting and searching.