1Z0-811 Primitives, Strings and Operators Practice Question
A developer needs to store a currency value with two decimal places. Which primitive type is most appropriate?
⚠ Common exam trap
Many candidates choose float thinking it is sufficient for decimal values, but they overlook that double is the default type for decimal literals in Java and provides greater precision, which is critical for currency to avoid rounding errors in calculations.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
double
(double) is the most appropriate primitive type for storing a currency value with two decimal places because double is a 64-bit IEEE 754 floating-point type that can represent fractional values with sufficient precision for typical monetary amounts. While float (32-bit) could also store decimals, double provides higher precision (15-16 significant digits) and is the default type for decimal literals in Java, making it the standard choice for currency calculations in the exam context.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
float
Why it's wrong here
Less precision than double, but still floating-point; double is more common.
- ✓
double
Why this is correct
`double` is a primitive floating-point data type, making it suitable for representing decimal numbers like currency values. Its 64-bit precision allows for storing fractional parts, directly addressing the requirement for two decimal places. Among the available primitive types, `double` offers the best balance of range and precision for general-purpose decimal arithmetic, making it the most appropriate choice when a primitive type is specified for currency representation.
- ✗
long
Why it's wrong here
Integer type.
- ✗
int
Why it's wrong here
Cannot represent decimals.
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.