Skip to content
Sharp

Object-oriented programming · interview question

Which principle of OOP is demonstrated by a 'Product' class having a method that checks its own stock level?

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

Correct answer

B. Encapsulation

Why

Encapsulation is demonstrated by the 'Product' class having a method to check its own stock level. It bundles the data (stock level) with the method that operates on that data, ensuring the internal representation is hidden from outside.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →