--- title: Intermediate Java OOP collection: Java Oops author: Suraj Kumar Jha updated: 2026-09-29 source: https://docs.chaicode.com/java-oops/intermediate-java-oop --- # Intermediate Java OOP ![A master Swiggy class holding a shared 'platformFee = 6' variable pointing down to User A and User B objects.](https://docs.chaicode.com/cdn-cgi/image/width=1600,format=auto,fit=scale-down/assets/6090344a3dccfe61feb7bc01c903027f8e328a6c94b1549bfc78a594abe1c330.jpg) static: Common to All Objects — 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`. ![A utility box labeled 'PhonePeUPI' executing pay() directly without creating a User object.](https://docs.chaicode.com/cdn-cgi/image/width=1600,format=auto,fit=scale-down/assets/e3c6ed9874b6f6ab2da5842b773f2a3da323146f8d9987c6bba004775ddd7aae.jpg) Static Variables & Methods — 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! ![Memory split showing Class Area storing shared static data vs Heap storing separate user objects s1 and s2.](https://docs.chaicode.com/cdn-cgi/image/width=1600,format=auto,fit=scale-down/assets/675ac2d1a52ac495694eb9dd70a6c0cd41706b311ab2688007cfbb5aec3fe994.jpg) Static Blocks & Memory Model — 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. ![Padlock icons stamped onto an Aadhaar variable, a payment process method, and a security class.](https://docs.chaicode.com/cdn-cgi/image/width=1600,format=auto,fit=scale-down/assets/87f75aba9f49b2c4a0adf10b97adb5b1730693a740de9efbf0eadc2a82779de5.jpg) final: Lock Down Changes — 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).