Java Static Keyword Clarified: Misconceptions and Facts

Today I revised the static keyword in Java and cleared a few common misconceptions. - Static Block It runs once when the class is loaded, not when the JVM starts. It executes before main() and before any object is created. - Static Methods Static methods cannot be overridden. They belong to the class, so method calls are decided at compile time method hiding. - Static Variables Static variables are shared across all objects and can change. Only static final variables act like constants. Small concepts, but very important for interviews and real-world Java coding, stay tuned for more tech posts ! 🤩 #Java #LearningJava #OOP #Programming #JavaDeveloper

Instance block: without name called whenever object of class is created. Sequence of execution: Static block Main method Instance block Constructor

Like
Reply

What's the role of a static constructor?

Like
Reply

Appreciate this! Such a fundamental Java concept explained clearly.

See more comments

To view or add a comment, sign in

Explore content categories