LearnFrenzy
Sign in Take a free test

OOP in Python · Predict the Output · Question 10

Calling a staticmethod Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

What is the output of the following Python program?

main.py
class MathUtil:
    @staticmethod
    def is_even(n):
        return n % 2 == 0

m = MathUtil()
print(MathUtil.is_even(4), m.is_even(7))
  • A TypeError
  • B False True
  • C True False Correct
  • D True True
Correct Answer: Option C

A static method can be called through the class or an instance; no self is passed either way.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links