Vidyalelo
Python · Q14

Decorators in Depth

Programming · Python · question 14

Q14

How does the @classmethod decorator differ from @staticmethod?

A.
@classmethod can't access class attributes
B.
@staticmethod can't access instance attributes
C.
@classmethod can access class attributes
Answer
D.
@staticmethod can access instance attributes

Answer: Option C

Solution

Answer: Option C
Solution:
The @classmethod decorator can access class attributes, while @staticmethod cannot.