Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 6)
6.
What is the purpose of the @classmethod decorator?
It defines a class method that can be called on an instance.
It is used to create a static method in a class.
It marks a method as abstract and must be implemented in derived classes.
It indicates a method that takes the class as its first parameter.
Answer: Option
Explanation:
The @classmethod decorator in Python is used to define a class method. A class method takes the class as its first parameter, conventionally named cls, allowing it to access and modify class-level attributes.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.