nerdexam
Oracle

1Z0-804 · Question #140

Given: Which two statements, inserted independently at line ***, enable the program to produce the following output: We have 002 Blue pants that cost $24.99.

The correct answer is A. System.out.printf("We have %03d %s pants that cost $%3.2f.\n",quantity, color, price); C. String out = String.format ("We have %03d %s pants that cost $%3.2f.\n",quantity, color,price). See the full explanation below for the reasoning.

Question

Given:

Which two statements, inserted independently at line ***, enable the program to produce the following output:

We have 002 Blue pants that cost $24.99.

Options

  • ASystem.out.printf("We have %03d %s pants that cost $%3.2f.\n",quantity, color, price);
  • BSystem.out.printf("We have$03d$s pants that cost $$3.2f.\n",quantity, color, price);
  • CString out = String.format ("We have %03d %s pants that cost $%3.2f.\n",quantity, color,price);
  • DString out = System.out.format("We have %03d %s pants that cost $%3.2f.",quantity, color, price);
  • ESystem.out.format("We have %s%spants that cost $%s.\n",quantity, color, price);

How the community answered

(22 responses)
  • A
    73% (16)
  • B
    9% (2)
  • D
    5% (1)
  • E
    14% (3)

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice