Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 7)
7.
What is the purpose of the @staticmethod decorator?
It is used to define a method that only operates on instance variables.
It indicates a method that can be called without creating an instance of the class.
It marks a method as private and inaccessible from outside the class.
It specifies a method that cannot be overridden in derived classes.
Answer: Option
Explanation:
The @staticmethod decorator is used to define a static method in a class. Static methods are not bound to an instance and can be called on the class itself without creating an object.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.