Oracle
1Z0-803 · Question #43
Given: public class x{ public static void main (string [] args){ String theString = "Hello World"; System.out.println(theString.charAt(11)); } } What is the result?
The correct answer is C. AStringIndexOutOfBoundsException is thrown at runtime. The code compiles fine. At runtime an IndexOutOfBoundsException is thrown when the second list item is added.
Working with Selected Classes from the Java API
Question
Given:
public class x{ public static void main (string [] args){ String theString = "Hello World"; System.out.println(theString.charAt(11)); } } What is the result?
Options
- AThere is no output
- Bd is output
- CAStringIndexOutOfBoundsException is thrown at runtime
- DAnArrayIndexOutOfBoundsException is thrown at runtime
- EA NullPointException is thrown at runtime
- FA StringArrayIndexOutOfBoundsException is thrown at runtime
How the community answered
(20 responses)- A5% (1)
- C85% (17)
- D5% (1)
- E5% (1)
Explanation
The code compiles fine. At runtime an IndexOutOfBoundsException is thrown when the second list item is added.
Topics
#String methods#charAt()#StringIndexOutOfBoundsException
Community Discussion
No community discussion yet for this question.