Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What is a static method?

View

Which decorator is used to define a static method?

View

Which method can access both class and instance attributes?

View

How do you call a class method?

View

What is the first argument of a class method?

View

Which of the following statements is true?

View

Which of the following methods is shared among all instances?

View

What is the difference between classmethod and staticmethod?

View

What is the output of this code?

View

Can a class method modify instance attributes?

View

What is a static method?

A method that works only with class variables
A method that does not modify class or instance state
A method that modifies instance variables
A method that works only with private attributes

Which decorator is used to define a static method?

@classmethod
@staticmethod
@function
@abstractmethod

Which method can access both class and instance attributes?

Static method
Class method
Instance method
Both b and c

How do you call a class method?

Using self.method()
Using Class.method()
Using object.method()
All of the above

What is the first argument of a class method?

self
class
cls
object

Which of the following statements is true?

Static methods can modify instance variables
Class methods work only with instance attributes
Both class and static methods can be called on instances
Static methods require self

Which of the following methods is shared among all instances?

Static method
Instance method
Private method
Getter method

What is the difference between classmethod and staticmethod?

classmethod takes self as the first argument
staticmethod has no access to class or instance data
Both can access private data
There is no difference

What is the output of this code?

class A: @staticmethod def greet(): print("Hello") A.greet()

Error
Hello
None
Static method not found

Can a class method modify instance attributes?

Yes
No
Only when using self
Only with staticmethod