1Z0-829 Practice Question: Handling Date, Time, Text, Numeric and Boolean Values
Which of the following correctly formats a NumberFormat instance to display a currency value for the US locale with exactly two decimal places, rounding half-up?
⚠ Common exam trap
The trap is that candidates may think getCurrencyInstance already sets HALF_UP, but it defaults to HALF_EVEN. Option D appears simplest but fails the rounding requirement. Option A explicitly sets the rounding mode, making it the correct choice.
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
✓
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); nf.setRoundingMode(RoundingMode.HALF_UP);
It uses NumberFormat.getCurrencyInstance(Locale.US) which defaults to exactly two decimal places for the US locale, and explicitly sets the rounding mode to RoundingMode.HALF_UP, satisfying both requirements. Options B and C adjust fraction digits but do not set the rounding mode, so they default to HALF_EVEN. Option D also defaults to HALF_EVEN, not HALF_UP. Therefore, only option A meets the conditions of exactly two decimal places and rounding half-up.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); nf.setRoundingMode(RoundingMode.HALF_UP);
Why this is correct
Correct. getCurrencyInstance(Locale.US) provides two decimal places by default, and setRoundingMode(HALF_UP) ensures half-up rounding.
- ✗
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); nf.setMinimumFractionDigits(2);
Why it's wrong here
Incorrect. Setting minimum fraction digits does not affect the rounding mode; it defaults to HALF_EVEN.
- ✗
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); nf.setMaximumFractionDigits(2);
Why it's wrong here
Incorrect. Setting maximum fraction digits does not affect the rounding mode; it defaults to HALF_EVEN.
- ✗
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US);
Why it's wrong here
Incorrect. While getCurrencyInstance provides two decimal places, it defaults to HALF_EVEN rounding, not half-up.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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-829 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-829 exam.