nerdexam
Oracle

1Z0-819 · Question #193

Given: ``java public class Tester { public static void main(String[] args) { String s = "Hat at store"; String t = new String("Hat"); s.substring(s.indexOf(' ') + 1); s.concat(" at home"); String x…

The correct answer is E. Hat at store 1. See the full explanation below for the reasoning.

Question

Given: ```java public class Tester { public static void main(String[] args) { String s = "Hat at store"; String t = new String("Hat"); s.substring(s.indexOf(' ') + 1); s.concat(" at home"); String x = t.substring(t.indexOf(' ')); System.out.println(s + " " + x); } }
What is the result?

Options

  • AAn IndexOutOfBoundsException is thrown at runtime.
  • BHat at home
  • CHat at store
  • DAt once
  • EHat at store 1

How the community answered

(45 responses)
  • A
    4% (2)
  • B
    13% (6)
  • C
    9% (4)
  • D
    2% (1)
  • E
    71% (32)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice