nerdexam
Oracle

1Z0-850 · Question #3

Given: 18. String s = " abcdcb a "; 19. int x = 2; 20. s = s.trim(); 21. if (s.length() < 8) { 22. x = s.indexOf('c', 3); 23. } 24. System.out.println("x = " + x); What is the result?

The correct answer is D. x = 4. See the full explanation below for the reasoning.

Question

Given: 18. String s = " abcdcb a "; 19. int x = 2; 20. s = s.trim(); 21. if (s.length() < 8) { 22. x = s.indexOf('c', 3); 23. } 24. System.out.println("x = " + x); What is the result?

Options

  • Ax = 5
  • Bx = 3
  • Cx = 6
  • Dx = 4
  • Ex = 2

How the community answered

(15 responses)
  • B
    13% (2)
  • C
    7% (1)
  • D
    80% (12)

Community Discussion

No community discussion yet for this question.

Full 1Z0-850 Practice