Classes & Objects · Question 14 · Medium

What is the key difference between a method marked @classmethod and one marked @staticmethod?

  1. A static method can be called only on an object, never on the class
  2. A class method cannot be inherited by child classes, but a static method can
  3. A static method automatically receives the object as its first argument; a class method receives nothing
  4. A class method automatically receives the class as its first argument; a static method receives no automatic argument
Answer and explanation

Answer: D. A class method automatically receives the class as its first argument; a static method receives no automatic argument

Explanation: @classmethod passes the class (usually named cls) as the first argument, so it can read or change class-level data. @staticmethod is a plain function kept inside the class and gets neither self nor cls.

Previous: fahrenheit is declared with @property and is accessed without brackets. What… · Next: B is a child of A. What do isinstance, a direct type comparison and issubclass…

Practise classes & objects

Try a fresh set of classes & objects questions with an explanation after every answer, free and without signing up: Classes & Objects practice. Or sit a full placement mock test.

More classes & objects questions

More python practice

Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge