Java OCA OCP Practice Question 2552

Question

Which of the options when inserted at //INSERT CODE HERE will format the currency for Locale with the language German (de)?.

double amt = 12345.1111;
//INSERT CODE HERE
System.out.println(format.format(amt));
a  Locale.setDefault(Locale.GERMAN);
   NumberFormat format = NumberFormat.getCurrencyInstance();

b  CurrencyFormat format = CurrencyFormat.getCurrencyInstance(Locale.GERMAN);

c  NumberFormat format = NumberFormat.getInstance("currency", Locale.GERMAN);

d  NumberFormat format = NumberFormat.getCurrencyInstance(new Locale("de"));


a, d

Note

Option (b) is incorrect because it uses a nonexistent class CurrencyFormat.

Option (c) is incorrect because it uses a nonexistent getInstance() method that accepts a type of the formatter to be returned and a Locale.




PreviousNext

Related