Java is one of the most influential and widely used programming languages in the world. Designed with portability, performance, security, and scalability in mind, Java powers everything from enterprise backends and Android applications to financial systems and distributed platforms.
1. What Is Java?
Java is a high-level, statically typed, object-oriented, compiled + interpreted language developed by Sun Microsystems (now Oracle).
Core goals of Java
- Write Once, Run Anywhere (WORA)
- Platform independence
- Strong memory management
- Built-in concurrency
- Security by design
2. Java Architecture (High-Level)
Java follows a three-layer execution architecture:
Java Source Code (.java)
↓
Java Compiler (javac)
↓
Bytecode (.class)
↓
Java Virtual Machine (JVM)
↓
Native Machine Code
Key Components
- JDK (Java Development Kit) – compiler + tools
- JRE (Java Runtime Environment) – JVM + libraries
- JVM (Java Virtual Machine) – executes bytecode
3. Java Internal Architecture (JVM Deep Dive)
3.1 JVM Components
Class Loader
Runtime Data Areas
Execution Engine
JNI
Garbage Collector
3.2 Class Loader Subsystem
Loads .class files into memory.
Types:
- Bootstrap ClassLoader
- Extension ClassLoader
- Application ClassLoader
Process:
- Loading
- Linking
- Initialization
3.3 Runtime Data Areas (Memory Model)
Method Area
- Class metadata
- Static variables
- Constant pool
Heap
- Objects
- Arrays
Stack
- Method frames
- Local variables
PC Register
- Tracks instruction execution
Native Method Stack
- Used by JNI
4. Java Execution Engine
- Interpreter – executes bytecode line by line
- JIT Compiler – converts hot code to native code
- Garbage Collector – automatic memory cleanup
5. Java Garbage Collection (GC)
Java uses automatic memory management.
Common GC Algorithms:
- Serial GC
- Parallel GC
- G1 GC
- ZGC
- Shenandoah
Example:
MyObject obj = new MyObject();
obj = null; // eligible for GC
6. Java Language Syntax — Complete Coverage
7. Basic Java Program Structure
public class Main {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}
8. Data Types in Java
Primitive Types
| Type | Size |
|---|---|
| byte | 1 |
| short | 2 |
| int | 4 |
| long | 8 |
| float | 4 |
| double | 8 |
| char | 2 |
| boolean | JVM dependent |
int x = 10;
double pi = 3.14;
Reference Types
- Class
- Array
- Interface
- Enum
9. Variables
int a = 5; // local
static int b = 10; // static
10. Operators
Arithmetic:
a + b;
a - b;
a * b;
a / b;
Logical:
&& || !
Bitwise:
& | ^ << >> >>>
11. Control Flow Statements
If-Else
if (x > 0) {
System.out.println("Positive");
}
Switch
switch(day) {
case 1 -> System.out.println("Mon");
}
Loops
for(int i=0;i<5;i++){}
while(true){}
do{}while(false);
12. Methods (Functions)
static int add(int a, int b) {
return a + b;
}
Method Overloading:
add(int a, int b)
add(double a, double b)
13. Object-Oriented Programming in Java
Classes and Objects
class Car {
String brand;
void drive() {}
}
Car c = new Car();
Encapsulation
private int age;
public int getAge() {
return age;
}
Inheritance
class Animal {}
class Dog extends Animal {}
Polymorphism
Animal a = new Dog();
Abstraction
abstract class Shape {
abstract void draw();
}
Interfaces
interface Fly {
void fly();
}
14. Constructors
class User {
User(String name) {}
}
15. Static Keyword
static int count;
static void print(){}
16. Final Keyword
final int MAX = 100;
final class Secure {}
17. Packages and Imports
package com.app.core;
import java.util.*;
18. Exception Handling
try {
int x = 10 / 0;
} catch (ArithmeticException e) {
e.printStackTrace();
} finally {
System.out.println("Done");
}
Custom Exception:
class MyException extends Exception {}
19. Java Collections Framework
List
List<Integer> list = new ArrayList<>();
Set
Set<Integer> set = new HashSet<>();
Map
Map<String,Integer> map = new HashMap<>();
20. Generics
class Box<T> {
T value;
}
21. Lambda Expressions
(a, b) -> a + b;
22. Streams API
list.stream()
.filter(x -> x > 5)
.forEach(System.out::println);
23. Multithreading & Concurrency
Thread
class MyThread extends Thread {
public void run() {}
}
Runnable
new Thread(() -> {}).start();
Synchronization
synchronized void method() {}
24. Memory Model & volatile
volatile boolean running;
25. Java I/O
FileReader fr = new FileReader("a.txt");
26. NIO (New I/O)
Files.readAllLines(Path.of("a.txt"));
27. Serialization
class User implements Serializable {}
28. Annotations
@Override
@Deprecated
Custom:
@interface MyAnno {}
29. Reflection API
Class<?> c = Class.forName("MyClass");
30. JVM Tools
- javac
- java
- javadoc
- jstack
- jmap
- jconsole
31. Java Modules (JPMS)
module my.module {
requires java.sql;
}
32. Java Versions & Modern Features
- Java 8 → Lambdas, Streams
- Java 11 → LTS
- Java 17 → Records, Sealed classes
- Java 21 → Virtual Threads (Project Loom)
33. Virtual Threads (Modern Java)
Thread.startVirtualThread(() -> {
System.out.println("Virtual");
});
34. Where Java Is Used
- Backend (Spring, Quarkus)
- Android
- Banking systems
- Distributed systems
- Big data (Hadoop)
35. Final Thoughts
Java remains one of the most powerful, stable, and enterprise-ready languages ever created. Its robust architecture, rich standard library, and modern language evolution make it relevant even decades after its birth.
If you fully understand Java internals + syntax, you can confidently build scalable, high-performance, production-grade systems.
Top comments (0)