Java OCA OCP Practice Question 2424

Question

Which option, when used as a format specifier, will format the decimal literal value 14562975.6543 to use at least the locale-specific grouping separator and include a sign with it (+ or -)? (Choose all that apply.)

  • a %+,3f
  • b %,+20f
  • c %+,f
  • d %,+f
  • e %()f
  • f %-,f
  • g %0.+f


a, b, c, d

Note

You must use the following for the required format:

  • %f
  • Flag + to include a sign
  • Flag , to use locale-specific grouping

Options (a), (b), (c), and (d) use the correct format specifier, %f.

The flags + and , can appear in any order.

It's acceptable to specify the width of the numeric literal.

If the total width specified with the format specifier is less than the width of the argument passed to it, it's ignored.

If the width specified after the decimal is less than the number of digits stored by the value to be formatted, it's rounded off.

Options (e), (f), and (g) are incorrect.

They either include an invalid combination of flags or don't include the required flags.




PreviousNext

Related