In this tutorial, you’ll understand the difference between class method vs. static method vs. instance method step by step.
In Object-oriented programming, when we design a class, we use the following three methods
- Instance method performs a set of actions on the data/value provided by the instance variables. If we use instance variables inside a method, such methods are called instance methods.
- Class method is method that is called on the class itself, not on a specific object instance. Therefore, it belongs to a class level, and all class instances share a class method.
- Static method is a general utility method that performs a task in isolation. This method doesn’t have access to the instance and class variable.