nerdexam
Oracle

1Z0-850 · Question #16

Given: 6. int time = 12; 7. if ( time < 12 ) { 8. System.out.println("Good morning"); 9. } 10. // insert code here 11. System.out.println("Good afternoon"); 12. } 13. else if ( time >= 18 ) { 14…

The correct answer is A. else if (time > 12 || time <= 18) { C. if (time >= 12 && time < 18) { D. else if (time >= 12 || time < 18) {. See the full explanation below for the reasoning.

Question

Given: 6. int time = 12; 7. if ( time < 12 ) { 8. System.out.println("Good morning"); 9. } 10. // insert code here 11. System.out.println("Good afternoon"); 12. } 13. else if ( time >= 18 ) { 14. System.out.println("Good evening"); 15. } Which three, inserted independently at line 10, produce the output Good afternoon? (Choose three.)

Options

  • Aelse if (time > 12 || time <= 18) {
  • Belse if (time > 12 && time <= 18) {
  • Cif (time >= 12 && time < 18) {
  • Delse if (time >= 12 || time < 18) {
  • Eelse if (time < 12 || time > 18) {

How the community answered

(47 responses)
  • A
    74% (35)
  • B
    9% (4)
  • E
    17% (8)

Community Discussion

No community discussion yet for this question.

Full 1Z0-850 Practice