nerdexam
Oracle

1Z0-804 · Question #98

Select four examples that initialize a NumberFormat reference using a factory.

The correct answer is C. NumberFormat nf3 = NumberFormat.getInstance(); D. NumberFormat nf4 = NumberFormat.getIntegerInstance(); E. NumberFormat nf5 = DecimalFormat.getNumberInstance (); F. NumberFormat nf6 = NumberFormat.getCurrencyInstance (). public static finalNumberFormatgetInstance() Returns the default number format for the current default locale. The default format is one of the styles provided by the other factory methods: getNumberInstance(E), getIntegerInstance(D), getCurrencyInstance(F) or…

Localization

Question

Select four examples that initialize a NumberFormat reference using a factory.

Options

  • ANumberFormat nf1 = new DecimalFormat();
  • BNumberFormat nf2 = new DecimalFormat("0.00") ;
  • CNumberFormat nf3 = NumberFormat.getInstance();
  • DNumberFormat nf4 = NumberFormat.getIntegerInstance();
  • ENumberFormat nf5 = DecimalFormat.getNumberInstance ();
  • FNumberFormat nf6 = NumberFormat.getCurrencyInstance () ;

How the community answered

(36 responses)
  • A
    6% (2)
  • B
    14% (5)
  • C
    81% (29)

Explanation

public static finalNumberFormatgetInstance() Returns the default number format for the current default locale. The default format is one of the styles provided by the other factory methods: getNumberInstance(E), getIntegerInstance(D), getCurrencyInstance(F) or getPercentInstance. Exactly which one is locale dependant. C: To obtain a NumberFormat for a specific locale, including the default locale, call one of NumberFormat'sfactory methods, such as getInstance(). E:To obtain standard formats for a given locale, use the factory methods on NumberFormat such asgetNumberInstance. These factories will return the most appropriate sub-class of NumberFormat for a givenlocale. F:To obtain standard formats for a given locale, use the factory methods on NumberFormat such asgetInstance or getCurrencyInstance.

Topics

#NumberFormat#factory methods#getCurrencyInstance#getIntegerInstance

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice