Java-DSA-Note-1
Java-DSA-Note-1
1. History of Java
➤ Origin
Java was developed by James Gosling, Mike Sheridan, and Patrick Naughton at Sun
Microsystems in 1991.
The original project was called "Oak", named a er an oak tree outside Gosling’s office.
Oak was designed for consumer electronic devices like set-top boxes, microwaves, and
TV remotes.
In 1995, Oak was renamed to Java because “Oak” was already a trademark by another
company.
The name "Java" was inspired by Java coffee, a type of coffee from Indonesia.
The first official version of Java (Java 1.0) was released by Sun Microsystems in 1995.
➤ Acquisi on by Oracle
In 2010, Oracle Corpora on acquired Sun Microsystems, taking over Java's development
and licensing.
➤ Core Reasons:
o Java programs are compiled to an intermediate form called bytecode, which can
run on any device with a JVM.
o This gave birth to Java’s philosophy: “Write Once, Run Anywhere” (WORA).
2. Internet-Centric Programming
3. Security
o Java has a sandbox execu on model for running untrusted code (like in
browsers).
5. Object-Oriented Programming
o Java has built-in concurrency with threads, making it easy to write mul threaded
programs.
o Syntax similar to C/C++, but removes complex features like operator overloading
and mul ple inheritance using classes.
o Java balances performance and flexibility, becoming faster over me with Just-
In-Time (JIT) Compila on.
3. Java Programming Language Structure
Example Code:
java
CopyEdit
System.out.println("Hello, World!");
Key Elements:
Method: A block of code that performs a specific task. main() is the entry point.
➤ What is JVM?
┌─────────────────────┐
│ Class Loader │
└─────────────────────┘
┌─────────────────────┐
└─────────────────────┘
┌─────────────────────┐
│ Execu on Engine │
└─────────────────────┘
┌─────────────────────┐
│ Na ve Interface │
└─────────────────────┘
┌─────────────────────┐
│ Na ve Libraries │
└─────────────────────┘
Responsible for loading class files (.class), verifying, and preparing them for execu on.
➤ 1. Method Area
➤ 2. Heap
➤ 3. Java Stack
➤ 5. Na ve Method Stack
Used when Java interacts with the opera ng system via JNI.
5.3 Execu on Engine
Components:
1. Interpreter
3. Garbage Collector
o Uses algorithms like Mark and Sweep, Genera onal GC, G1 GC.
Java Na ve Interface is a bridge for Java code to call or be called by na ve applica ons
(C/C++).
Useful for:
5.5 Na ve Libraries
Pla orm-dependent.
2. Compila on: The Java compiler (javac) compiles code into .class files (bytecode).
Component Descrip on
JRE + development tools (compiler, debugger, etc.) — used for developing Java
JDK
applica ons.
Contains JVM
Contains Libraries
The JVM allows Java programs to run on any pla orm without modifica on.
JVM’s internal design ensures efficient memory management, robust execu on, and
security.
Understanding the JVM is cri cal for Java developers, especially for performance tuning
and debugging.