Skip to content
Sharp

Core Java · interview question

Consider a method that calculates the total price of items in a cart. What is a good naming convention for this method?

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

Correct answer

C. CalculateTotalPrice

Why

A good method name should be descriptive and indicate the action the method performs. 'calculateTotalPrice' clearly conveys that the method will compute the total price, making it easy to understand how it fits into the e-commerce workflow.

Test yourself on Core Java

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

Start free test
All Core Java questions →