Java OCA OCP Practice Question 2536

Question

What is the output of the following code?

NumberFormat fmt = new NumberFormat(Locale.US);
System.out.println(fmt.format(123123.99));
  • a 123123.99
  • b 123,123.99
  • c 1,23,123.99
  • d 123 123.99
  • e 1 23 123.99
  • f 123,124.00
  • g Compilation error
  • h Runtime exception


g

Note

Class NumberFormat is an abstract class-you can't instantiate it.

Class NumberFormat defines multiple factory methods to create and return an object of the relevant classes that implement NumberFormat, like getInstance(), getInstance(Locale), getNumberInstance(), and getNumberInstance(Locale).




PreviousNext

Related