Section 36.4 Formatting Numbers
13. Which of the following code is correct to create an instance for formatting numbers?
a. NumberFormat.getInstance();
b. NumberFormat.getNumberInstance(locale);
c. NumberFormat.getInstance(locale);
d. NumberFormat.getNumberFormatInstance(locale);
#
14. Which of the following code is correct to create an instance for formatting numbers in currency?
a. NumberFormat.getCurrencyInstance(locale);
b. NumberFormat.getCurrencyInstance();
c. NumberFormat.currencyInstance(locale);
d. NumberFormat.currencyInstance();
#
15. Which of the following code is correct to create an instance for formatting numbers in percent?
a. NumberFormat.getPercentInstance(locale);
b. NumberFormat.getPercentInstance();
c. NumberFormat.percentInstance(locale);
d. NumberFormat.percentInstance();
#
16. Which of the following are valid methods in NumberFormat?
a. format(double)
b. format(long)
c. setMaximumIntegerDigits(int)
d. setMinimumIntegerDigits(int)
#
17. Which of the following code displays the numbers with at least two digits before and after the decimal point?
a. NumberFormat numberForm = NumberFormat.getNumberInstance(); DecimalFormat df =
(DecimalFormat)numberForm;<br>df.applyPattern(“00.00”);
b.NumberFormat numberForm = NumberFormat.getNumberInstance(); numberForm.setMaximumFractionDigits(2);
numberForm.setMinimumFractionDigits(2);
c. NumberFormat numberForm =
NumberFormat.getNumberInstance();<br>numberForm.setMaximumFractionDigits(2);
#
18. Suppose that NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US). Which of the
following statement is legal?
a. Number number = NumberFormat.parse(“$5,000.56”);
b. Number number = currencyFormat.parse(“$5,000.56”);
c. Number number = currencyFormat.parseCurrency(“$5,000.56”);
d. Number number = currencyFormat.parse(“5,000.56”);
#
19. Which of the following statements are true?
a. DecimalFormat is a subclass of NumberFormat.