Skip to content
Sharp

Object-oriented programming · interview question

Why is it often unnecessary to make a method static in a class like CartItem?

Multiple choiceMediumchapter-2-curatedpremiumoopinstance-methods
Choose one answer
Answer and explanation

Correct answer

B. Because methods usually depend on instance variables.

Why

Most methods in classes like CartItem operate on instance variables that belong to a specific object instance. Making these methods static would prevent them from accessing instance-specific data.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →