note type, date, done
note type
date
done
2026-06-03
true
Java Concepts
1. Object-Oriented Programming Concepts
Inheritance
Definition : Mechanism where a class inherits properties and behaviors from another class
Syntax : public class Child extends Parent { }
Types : Single, Multilevel, Hierarchical
super keyword : Refers to parent class objects/constructors
Method Overriding : Child classes can provide specific implementation of methods
Encapsulation
Definition : Bundling data and methods that operate on the data within a single unit
Implementation : Using private fields with public getters/setters
Benefits : Hides implementation details, controls access, reduces code coupling
Polymorphism
Definition : Ability of objects to take different forms
Types :
Compile-time (Method Overloading) : Multiple methods with same name but different parameters
Runtime (Method Overriding) : Subclass implementing parent class method
Example :
Abstraction
Definition : Hiding implementation details, showing only functionality
Implementation : Through abstract classes and interfaces
Abstract Classes : Can have both concrete and abstract methods
Interfaces : Collection of abstract methods (default/static methods allowed in Java 8+)
2. Java Syntax and Language Features
Basic Structure
Access Modifiers
public : Accessible from anywhere
protected : Accessible within package and by subclasses
default (no modifier) : Accessible only within package
private : Accessible only within class
Non-Access Modifiers
static : Belongs to class rather than instance
final : Cannot be extended (class), overridden (method), or changed (variable)
abstract : Cannot be instantiated (class), must be implemented (method)
synchronized : Controls thread access to method/block
volatile : Variable value always read from main memory
3. Data Types, Variables, and Operators
Primitive Data Types
Type
Size
Range
Default
byte
8 bits
-128 to 127
0
short
16 bits
-32,768 to 32,767
0
int
32 bits
-231 to 231 -1
0
long
64 bits
-263 to 263 -1
0L
float
32 bits
~3.40282347 x 1038
0.0f
double
64 bits
~1.79769313486231570 x 10308
0.0d
char
16 bits
0 to 65,535
'\u0000'
boolean
1 bit
true/false
false
Reference Types
Classes : String, custom classes
Arrays : int[], String[]
Interfaces : Collections interfaces
Wrapper Classes : Integer, Boolean, etc.
Variable Declaration
Operators
Arithmetic : +, -, *, /, %, ++, --
Relational : ==, !=, >, <, >=, <=
Logical : &&, ||, !
Bitwise : &, |, ^, ~, <<, >>, >>>
Assignment : =, +=, -=, *=, /=, etc.
Ternary : condition ? expr1 : expr2
instanceof : Tests if object is instance of class/interface
4. Control Flow Statements
Conditional Statements
Loops
Control Statements
break : Exits loop or switch
continue : Skips to next iteration
return : Exits method, optionally returning value
yield : Returns value from switch expression (Java 14+)
5. Exception Handling
Exception Hierarchy
Throwable : Base class for all exceptions
Error : Serious problems, not typically caught
Exception : Base for checked exceptions
- RuntimeException : Base for unchecked exceptions
Try-Catch-Finally
Try-With-Resources
Throwing Exceptions
Creating Custom Exceptions
Checked vs. Unchecked Exceptions
Checked : Must be caught or declared (IOException, SQLException)
Unchecked : Not required to be caught (RuntimeException and subclasses)
6. Java Collections Framework
Main Interfaces
Collection : Root interface
List : Ordered collection (allows duplicates)
Set : No duplicates
Queue : Typically FIFO order
Map : Key-value pairs
Common Implementations
Lists :
ArrayList: Dynamic array, fast random access
LinkedList: Fast insertions/deletions
Vector: Synchronized version of ArrayList
Sets :
HashSet: Fast operations, no order guarantee
LinkedHashSet: Preserves insertion order
TreeSet: Sorted set (implements SortedSet)
Maps :
HashMap: Fast operations, no order guarantee
LinkedHashMap: Preserves insertion order
TreeMap: Sorted by keys (implements SortedMap)
Hashtable: Synchronized version of HashMap
Queues :
ArrayDeque: Resizable array implementation
PriorityQueue: Elements processed by priority
Usage Examples
7. Generics
Basic Syntax
Wildcards
Type Parameters
Type Parameter Naming Conventions :
E: Element
K: Key
V: Value
N: Number
T: Type
S, U, V, etc.: Additional types
Type Erasure
During compilation, generic type information is removed ("erased")
Runtime doesn't have access to generic type information
8. Functional Interfaces and Lambda Expressions
Functional Interfaces
Interface with exactly one abstract method
Annotated with @FunctionalInterface
Common functional interfaces:
Predicate<T>: Takes T, returns boolean (boolean test(T t))
Consumer<T>: Takes T, returns void (void accept(T t))
Function<T,R>: Takes T, returns R (R apply(T t))
Supplier<T>: Takes nothing, returns T (T get())
BinaryOperator<T>: Takes two T, returns T (T apply(T t1, T t2))
Lambda Expressions
Method References
9. Streams API
Creating Streams
Common Operations
Intermediate Operations (return a stream):
filter(Predicate): Filters elements
map(Function): Transforms elements
flatMap(Function): Transforms and flattens
sorted(): Sorts elements
distinct(): Removes duplicates
limit(n): Limits size
skip(n): Skips elements
Terminal Operations (produce a result):
forEach(Consumer): Processes each element
collect(Collector): Gathers elements
reduce(BinaryOperator): Reduces to single value
count(): Counts elements
anyMatch(Predicate): Tests if any match
allMatch(Predicate): Tests if all match
noneMatch(Predicate): Tests if none match
findFirst(), findAny(): Finds elements
Example
10. Multithreading and Concurrency
Thread Creation
Thread Lifecycle
New : Created but not started
Runnable : Started, waiting for scheduler
Blocked : Waiting for monitor lock
Waiting : Called wait() without timeout
Timed Waiting : Called sleep() or wait() with timeout
Terminated : Completed execution
Thread Synchronization
Concurrent Collections
ConcurrentHashMap : Thread-safe HashMap
CopyOnWriteArrayList : Thread-safe ArrayList
BlockingQueue : Queue with blocking operations
Thread Pools (ExecutorService)
Atomic Variables
Thread Communication
wait() : Causes thread to wait until notify/notifyAll
notify() : Wakes up one waiting thread
notifyAll() : Wakes up all waiting threads
join() : Waits for thread to die
Original Outline
1. Object-Oriented Programming (OOP) in Java
Encapsulation (Access Modifiers: private, protected, public, default)
Abstraction (abstract classes, interfaces, default methods in interfaces)
Inheritance (extends, method overriding, super keyword, constructor chaining)
Polymorphism (Compile-time vs. Runtime, method overloading vs. method overriding)
Composition vs. Inheritance (Why favor composition over inheritance?)
SOLID Principles (How they apply in Java)
JavaBeans and POJOs (Plain Old Java Objects)
2. Java Data Types and Memory Management
Primitive vs. Reference Types
Wrapper classes (Integer, Double, Boolean, etc.)
String handling (String, StringBuilder, StringBuffer, immutability)
Autoboxing and Unboxing
Memory Allocation (Heap vs. Stack)
Garbage Collection (How it works, finalize(), weak references, types of GC algorithms)
3. Java Collections Framework (JCF)
List Interface (ArrayList, LinkedList, Vector, Stack)
Set Interface (HashSet, TreeSet, LinkedHashSet)
Map Interface (HashMap, TreeMap, LinkedHashMap, Hashtable)
Queue Interface (PriorityQueue, Deque, ArrayDeque)
Concurrent Collections (ConcurrentHashMap, CopyOnWriteArrayList)
Sorting and Searching in Collections (Comparable vs. Comparator)
Big-O Complexity of Collection Operations
Immutable Collections (List.of(), Set.of(), Map.of())
4. Exception Handling
Checked vs. Unchecked Exceptions
Custom Exceptions
Try-Catch-Finally vs. Try-With-Resources (AutoCloseable)
Throw vs. Throws
Multi-catch blocks (catch (IOException | SQLException e))
Best Practices for Exception Handling (Avoiding Generic Exceptions)
5. Java Multithreading and Concurrency
Thread Lifecycle
Creating Threads (Thread vs. Runnable, Callable, Future)
Synchronization (synchronized keyword, locks, ReentrantLock, wait(), notify())
Thread Safety and Shared Resource Handling
Executors and Thread Pools (ExecutorService, ScheduledExecutorService)
Atomic Variables (AtomicInteger, AtomicBoolean)
Fork-Join Framework
Deadlocks, Race Conditions, and Livelocks
6. Java Streams and Functional Programming
Lambda Expressions ((a, b) -> a + b)
Method References (Class::methodName)
Functional Interfaces (Predicate, Consumer, Supplier, Function, BiFunction)
Streams API (Intermediate vs. Terminal Operations)
Stream Processing (map(), filter(), reduce(), collect())
Parallel Streams (parallelStream())
Optional Class (Optional, avoiding null)
7. Java Input/Output (I/O) and Serialization
Byte Streams vs. Character Streams (InputStream, OutputStream, Reader, Writer)
File Handling (File, Files, BufferedReader, BufferedWriter)
Object Serialization (Serializable, transient keyword)
New I/O (NIO) (Path, Files, ByteBuffer, Channels)
Memory-Mapped Files
Java 11+ Features (Files.writeString(), Files.readString())
8. Java 8+ Features
Default and Static Methods in Interfaces
Optional Class
New Date and Time API (LocalDate, LocalTime, LocalDateTime, ZonedDateTime)
CompletableFuture (thenApply(), thenAccept(), exceptionally())
New Collection Methods (List.of(), Set.of(), Map.of())
Records (Java 14+)
Pattern Matching (Java 17+)
Sealed Classes (Java 17+)
9. Java Reflection and Dynamic Class Loading
Getting Class Information (.class, Class.forName())
Accessing Private Fields and Methods
Dynamic Proxy and InvocationHandler
Annotations and Annotation Processing
10. Java Networking (Sockets, HTTP)
Java Sockets (ServerSocket, Socket)
URL and HttpURLConnection
HTTP Clients (Java 11 HttpClient)
Multithreaded Server Applications
11. Java Security Basics
Encryption and Hashing (AES, SHA, RSA)
Java Cryptography API (MessageDigest, Cipher)
Secure Random Numbers (SecureRandom)
Security Manager (doPrivileged())
Understanding Java Classloaders and Security Policies
12. Java Virtual Machine (JVM) Internals
JVM Architecture (ClassLoader, Method Area, Heap, Stack, Execution Engine, Garbage Collector)
Class Loading (ClassLoader, Bootstrap, Extensions, Application ClassLoader)
JIT Compilation (Just-In-Time Compiler)
Garbage Collection Algorithms (G1, ZGC, Epsilon GC)
JVM Performance Tuning (-Xms, -Xmx, -XX:+UseG1GC)