Static Methods
TLDR: Static methods are methods declared static with the `static` keyword in programming languages like Java, CPP, and C Sharp. Unlike instance methods, static methods belong to the class itself rather than any specific object. They are often used for operations that do not depend on instance-specific data, such as utility functions, calculations, or shared operations. These methods can be called directly using the class name, simplifying access and usage.
https://en.wikipedia.org/wiki/Method_(computer_programming)
Static methods do not require object instantiation and are accessed using the syntax `ClassName.methodName()`. This characteristic makes them ideal for reusable functionality that applies to all instances of the class, such as mathematical operations or configuration utilities. Because static methods lack a reference to `this`, they cannot access non-static fields or invoke instance methods directly. This design ensures that static methods remain independent and focused on shared operations.
https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html
While static methods offer OOP performance benefits by avoiding the overhead of object creation, they have limitations. They cannot participate in polymorphism because they are bound to the class at compile time, meaning they cannot be overridden in the traditional sense. Instead, method hiding occurs when a subclass declares a static method with the same name. Properly using static methods enhances modularity and ensures clear separation between instance-specific and class-wide operations.
https://docs.oracle.com/javase/specs/jls/se20/html/jls-8.html