Skip to content
Sharp

Object-oriented programming · interview question

Given a superclass method protected void calculate(), which of the following correctly overrides it in a subclass?

Multiple choiceHardchapter-5-curatedpremiumoopmethod-overriding
Choose one answer
Answer and explanation

Correct answer

B. Protected void calculate()

Why

The overridden method must have the same signature, and it must not be more restrictive. It can be less restrictive, so 'protected void calculate()' is a correct override.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →