Java Methods & JVM Execution Fundamentals

📘 Day 15 ,16,17– Understanding Methods in Java & JVM Execution On Day 15,16,17 I explored one of the most fundamental building blocks of Java — Methods. 🔹 What is a Method? A method is a block of code defined inside a class that performs a specific task. It improves code reusability, readability, and modularity. 🔹 Method Signature Includes: Access specifier Return type Method name Parameters (inside parentheses) 🔹 Types of Methods in Java: No Input, No Output No Input, With Output With Input, No Output With Input, With Output 🔹 JVM & Memory Flow (Behind the Scenes): When program execution starts, the object is created in the Heap segment The reference variable is stored in the Stack segment Each method call creates a new stack frame After method execution, its stack frame is removed Finally, the main() method stack frame is removed Objects without references become garbage, collected by the Garbage Collector 🔹 Execution Order Java follows LIFO (Last In, First Out) principle in stack memory: Last method called → First method removed 🔹 Important Concept Parameters → Variables that receive values Arguments → Values passed to the method Understanding how methods work internally with the JVM helps write efficient, optimized, and interview-ready code. Learning step by step and enjoying the journey 🚀 #Java #CoreJava #MethodsInJava #JVM #StackAndHeap #LearningJourney #Day15 #ProgrammingConcepts

  • graphical user interface, text, application, chat or text message

To view or add a comment, sign in

Explore content categories