1.
Java Basics
- Java is a high-level, class-based, object-oriented programming language.
- It follows the WORA principle – Write Once, Run Anywhere.
- Main method: public static void main(String[] args)
2. Data Types, Variables, Operators
- Primitive Data Types: byte, short, int, long, float, double, char, boolean
- Variables must be declared with a type before use.
- Operators include arithmetic (+, -, *, /, %), relational (==, !=), logical (&&, ||, !), etc.
3. Type Casting
- Widening Casting: byte -> short -> int -> long -> float -> double
- Narrowing Casting: double -> float -> long -> int -> short -> byte
- Syntax: int i = (int) 10.5;
4. Control Statements
- if, if-else, switch-case for decision making
- Loops: for, while, do-while
5. Arrays
- One-dimensional array: int[] arr = new int[5];
- Two-dimensional array: int[][] matrix = new int[3][3];
6. Strings and StringBuilder
- String is immutable, use StringBuilder for mutable strings.
- String methods: length(), charAt(), substring(), indexOf(), etc.
7. OOPs Concepts
- Class and Object
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
8. Constructors & Overloading
- Constructors are used to initialize objects.
- Constructor overloading: multiple constructors with different parameters.
9. Method Overloading & Overriding
- Overloading: same method name with different parameters (compile-time).
- Overriding: subclass provides specific implementation (runtime).
10. Exception Handling
- try-catch-finally blocks handle exceptions.
- throw and throws for custom exceptions.
- Checked vs Unchecked exceptions.
11. Collections Framework
- Interfaces: List, Set, Map, Queue
- Classes: ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap
- Use Comparable and Comparator for sorting.
12. Multithreading
- Thread class and Runnable interface
- Thread lifecycle: New, Runnable, Running, Blocked, Terminated
- Synchronization, wait(), notify(), notifyAll()
13. File Handling
- Reading with FileReader and BufferedReader
- Writing with FileWriter and BufferedWriter
- NIO: Files.readAllLines(path), Files.write(path, data)