Skip to content
Sharp

Core Java · interview question

Which code correctly declare a variable to store a product's name?

Multiple choiceEasychapter-1-curatedpremiumcore-javavariables-and-data-types
Choose one answer
Answer and explanation

Correct answer

C. String productName;

Why

The 'String' data type is used to store sequences of characters, such as names. It is suitable for storing product names as they can contain spaces and various characters.

Test yourself on Core Java

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

Start free test
All Core Java questions →