Java OCA OCP Practice Question 121

Question

Which line prints double d in a left-justified field that is 20 characters wide, with 15 characters to the right of the decimal point?

  • A. System.out.format("%20.5f", d);
  • B. System.out.format("%20.15f", d);
  • C. System.out.format("%-20.5f", d);
  • D. System.out.format("%-20.15f", d);


D.

Note

The minus sign in the format string causes left-justification.

The number to the right of the decimal point in the format string controls the number of digits to the right of the decimal point in the output.




PreviousNext

Related