What is Java?
Java is a high-level, class-based, object-oriented programming language designed to
have as few implementation dependencies as possible. It is platform-independent due
to the Java Virtual Machine (JVM).
Java is a platform-independent, object-oriented, high-level programming language.
JDK, JRE, JVM
JDK: Java Development Kit – includes tools + JRE
JRE: Java Runtime Environment – for running Java apps
JVM: Java Virtual Machine – executes Java bytecode
Key Features of Java
Feature Description
Platform Independent Write Once, Run Anywhere (WORA) using JVM
Object-Oriented Everything is based on objects and classes
Simple & Secure Easy to learn and offers robust security
features
Robust & Reliable Handles errors through exception handling
Multi-threaded Supports concurrent execution of two or more
threads
High Performance With Just-In-Time (JIT) compiler
Distributed Can create distributed applications using RMI, EJB
Data Types
Primitive: int, float, double, char, boolean, long, short, byte
Non-Primitive: String, Arrays, Classes, Interfaces
| Type | Size | Example |
| ------- | ------- | ---------- |
| int | 4 bytes | 10 |
| float | 4 bytes | 10.5f |
| double | 8 bytes | 20.5 |
| char | 2 bytes | 'A' |
| byte | 1 byte | 127 |
| short | 2 bytes | 10000 |
| long | 8 bytes | 100000L |
| boolean | 1 bit | true/false |
Control Statements
Conditional-
if, else if, else,switch
Loop-
for, while, do-while
Branching-
break & continue
Object-Oriented Programming (OOP) Principles
Class: Blueprint for objects
Object: Instance of a class
Encapsulation: Using private fields and public methods
Inheritance: Acquiring properties from a parent class
Polymorphism: Method overloading/overriding
Abstraction: Hiding implementation details using abstract classes or interfaces
Summary Table
| Concept | Description | Keyword/Usage
|
| ------------- | ----------------------------------------- |
----------------------- |
| Class/Object | Template / Instance | `class`, `new`
|
| Encapsulation | Data hiding using private + getter/setter | `private`, `public`
|
| Inheritance | Acquiring properties from parent class | `extends`
|
| Polymorphism | One method, many forms |
Overloading/Overriding |
| Abstraction | Hiding implementation details | `abstract`,
`interface` |
String Handling
Immutable objects
Methods: length(), charAt(), substring(), equals(), compareTo(), concat()
Collections Framework
| Interface | Implementations |
| --------- | ------------------------------- |
| List | ArrayList, LinkedList |
| Set | HashSet, LinkedHashSet, TreeSet |
| Map | HashMap, LinkedHashMap, TreeMap |
| Queue | PriorityQueue, LinkedList |
Wrapper Classes
Convert primitive to object:
int → Integer
char → Character
Methods: parseInt(), valueOf()
File Handling (I/O)
Using File, FileReader, FileWriter, BufferedReader, BufferedWriter, Scanner
Access Modifiers
| Modifier | Access Level |
| --------- | ----------------------- |
| public | Everywhere |
| private | Within same class |
| protected | Same package + subclass |
| default | Same package |
Java Keywords
this, super, static, final, abstract, interface, extends, implements, new, return,
throw, throws, etc.
Java Memory Management
Stack (method calls, local variables)
Heap (objects)
Garbage Collection: Automatic memory cleanup