Skip to content
Sharp

Core Java · interview question

Given the method int addToCart(int currentQuantity, int newItems), what could be a potential return value?

Multiple choiceMediumchapter-1-curatedpremiumcore-javamethods
Choose one answer
Answer and explanation

Correct answer

C. The total quantity after adding new items.

Why

The method returns an integer, likely representing the total quantity after adding the new items to the current quantity in the cart.

Test yourself on Core Java

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

Start free test
All Core Java questions →