Instance Method and Class Method differences? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Instance Method and Class Method differences?

So a Class Method can be call only if we put the "class_name" + "." + "method_name" And the Instance Method can be call by class_name and object_name too?

11th Aug 2019, 12:07 AM
Nguyễn Tín
2 Answers
+ 1
Static methods and variables belong to the class and not objects of that class, when you think about it if a static variable only belongs to the class and there is only one class then that means there is only ever one copy of that static variable which makes it a class variable or method and not a instance method or variable, this means you can just access them without having to create an instance of class.
11th Aug 2019, 7:22 AM
D_Stark
D_Stark - avatar