chaidocs
Java Oops

Intermediate Java OOP

Suraj Kumar Jha 8 pages 1 min read Updated Sep 29, 2026
On this page
  1. static: Common to All Objects
  2. Static Variables & Methods
  3. Static Blocks & Memory Model
  4. final: Lock Down Changes
  5. Object Class: The Root Parent
  6. The Big Three Object Methods
  7. Packages & Imports
  8. Types of Inner Classes

static: Common to All Objects

01 A master Swiggy class holding a shared 'platformFee = 6' variable pointing down to User A and User B objects.
Notes
Belongs to the class itself, not to individual instances. Shared copy across every created object. Example: Platform fee on Swiggy — same ₹6 for all customer carts! Access directly via Class name: `Swiggy.platformFee`.

Static Variables & Methods

02 A utility box labeled 'PhonePeUPI' executing pay() directly without creating a User object.
Notes
Static Variable: One shared memory location for all objects. Static Method: Called directly without creating an object using `new`. Example: Calling `UPI.pay(500)` as a direct utility function. Rule: Static methods CANNOT directly access non-static instance variables!

Static Blocks & Memory Model

03 Memory split showing Class Area storing shared static data vs Heap storing separate user objects s1 and s2.
Notes
Static Block: Runs ONCE when the class is first loaded. Ideal for pre-loading setup data (e.g., fetching IRCTC server settings). Static members live in the Class level area. Instance members live inside separate Heap objects.

final: Lock Down Changes

04 Padlock icons stamped onto an Aadhaar variable, a payment process method, and a security class.
Notes
final variable: Value cannot be reassigned (like your 12-digit Aadhaar number). final reference: Object target is locked, but internal fields can change. final method: Cannot be overridden by any child class. final class: Cannot be extended/inherited (e.g., standard `String` class).