nerdexam
Oracle

1Z0-809 · Question #180

Given the code fragment: public static void main(String[] args) { double discount = 0; int qty = Integer.parseInt(args[0]); //line n1 } And given the requirements: If the value of the qty variable…

The correct answer is B. Option B C. Option C. You've hit your session limit · resets 10:20pm (America/New_York)

Question

Given the code fragment: public static void main(String[] args) { double discount = 0; int qty = Integer.parseInt(args[0]); //line n1 } And given the requirements:
  • If the value of the qty variable is greater than or equal to 90, discount = 0.5
  • If the value of the qty variable is between 80 and 90, discount = 0.2 Which two code fragments can be independently placed at line n1 to meet the requirements? A) discount = (qty >= 90) ? 0.5 : 0; B) discount = (qty >= 90) ? 0.5 : (qty >= 80) ? 0.2 : 0; C) if (qty >= 90) { discount = 0.5; } else if (qty >= 80 && qty < 90) { discount = 0.2; } D) discount = (qty >= 90) ? 0.2 : (qty >= 80) ? 0.5 : 0; E) if (qty >= 90) { discount = 0.5; } else if (qty >= 80) { discount = 0.2; } else { discount = 0; }

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D
  • EOption E

How the community answered

(56 responses)
  • A
    5% (3)
  • B
    79% (44)
  • D
    4% (2)
  • E
    13% (7)

Explanation

You've hit your session limit · resets 10:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice