Java OOP Fundamentals: State, Behavior, JRE, and Methods

🔹 OOP refresher: Every object has 2 parts: State / Properties (HAS-A) → coded using variables + data types Behavior (DOES) → coded using methods 🔹 Java Runtime (JRE) & Memory Segments: When a Java program runs in RAM, JRE is created with 4 segments: Code Segment Stack Segment (methods + local variables) Heap Segment (objects + instance variables) Static Segment (will learn later) 🔹 Variables recap: Instance variables → inside class → stored in heap (inside object) → default values given Local variables → inside method → stored in stack → no default values 🔹 Methods = Code Reusability ♻️ Instead of writing everything in main(), methods help us reuse logic and keep code clean. 🔹 4 Types of Methods (we covered 2 today): No input, No output No input, Output ✅ (Return concept) 🔹 Big clarity: ✅ System.out.println() = prints to console ✅ return = sends value back to the caller (If you return, main must handle/print it!) 🔹 Stack Frame concept: Whenever a method is called, a stack frame is created and pushed on stack (LIFO). After execution it gets popped ✅ 🔹 Heap & Garbage Collector: If an object has no reference, it becomes a garbage object, and Java’s GC automatically clears it 🧹 📌 Overall, today helped me understand not just the syntax — but the internal working of Java execution in a practical way. #Java #OOP #Programming #JRE #Stack #Heap #Methods #LearningJourney #Developer TAP Academy

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories