← Back to libraryQuestion 11 of 273
JavaBeginner

The Static Keyword

📖 Detailed Explanation:

The 'static' keyword means that a member (variable/method) belongs to the CLASS itself rather than any specific instance. Static members are initialized only once when the class is first loaded by the JVM, and there is only ONE copy shared among all instances. This makes static members suitable for constants and utility functions.

🌍 Real-World Example:

In a 'Student' class, the 'studentName' is instance-based (every student is different), but 'schoolName' is static (all students belong to the same school, and changing it affects all).

🎯 Scenario-Based Interview Question:

Why is the 'main' method always static in Java? What would happen if it were not?