Java JVM Execution Order and Static Variables

Day 29 of Learning Java 🚀 Today I went deeper into understanding how Java actually runs behind the scenes inside the JVM. Some interesting things I discovered today: ⚡ Learned the execution order in Java when a program has static variables → static blocks → instance variables → instance blocks → constructors → methods. ⚡ The JVM usually checks static members first. If there are no static members, execution starts from main() since it is also a static method. ⚡ Understood the use of static variables and how they save memory by storing values in a shared memory area (static segment / class area). ⚡ Learned that objects are also called instances. ⚡ Important concept: Instance variables cannot be accessed directly by static methods Static variables can be accessed by instance methods ⚡ Learned how static blocks can initialize static variables. ⚡ Explored JVM components like Class Loader, Interpreter, and JIT compiler. ⚡ Practiced compiling and running Java programs using Command Prompt (javac and java). ⚡ Also understood that the number of bytecode (.class) files generated depends on how many classes exist in the program. Small steps every day, but building strong Core Java fundamentals. 💻 #Day29 #Java #CoreJava #JVM #Programming #LearningJourney Harshit T

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories