Skip to content
Sharp

Modern Java · interview question

Why would you choose to use dedicated types like 'Email' instead of raw Strings?

Multiple choiceEasychapter-7-curatedpremiummodern-javavalue-objects
Choose one answer
Answer and explanation

Correct answer

C. To encapsulate specific validation logic

Why

Using dedicated types like 'Email' allows you to encapsulate validation logic specific to email addresses, such as format checking, ensuring that only valid emails are used throughout the application.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →