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)- A4% (2)
- B13% (6)
- C9% (4)
- D2% (1)
- E71% (32)
Community Discussion
No community discussion yet for this question.