Ch k Sh Correct false 3 What does userTextindexOf return 8 4 What is the index

Ch k sh correct false 3 what does usertextindexof

This preview shows page 3 - 6 out of 7 pages.

Ch k Sh Correct false
Image of page 3
3) What does userText.indexOf(',') return? 8 4) What is the index of the last character in userText? 13 5) What character does userText.charAt(userText.length() - 1) return? 4 6) What does userText.substring(0, 3) return? Mar 7) What does userText.substring(userText.length() - 4, userText.length()) return? 2034 A common error is to access an invalid array index, especially exactly one larger than the largest index. Given userText with size 8, the range of valid indices are 0..7; accessing with index 8 is an error. Check Show answer The string is not empty. Same as userText.length() == 0. Check Show answer Correct 8 ',' is the 9th character, so its index is 8. Check Show answer Correct 13 There are 14 characters, so the index of the last character is 13. Check Show answer Correct 4 That's one way to get the last character. Check Show answer Correct Mar String starting with M and ending with r. Check Show answer Correct 2034 That form gets the last 4 characters. Feedback?
Image of page 4
PARTICIPATION ACTIVITY 6.8.3: String access. The charAt(index) method generates an exception if the index is out of range for the string's size. An exception is a detected runtime error that commonly prints an error message and terminates the program. PARTICIPATION ACTIVITY 6.8.4: Out-of-range string access. Given userText = "Monday". 1) userText.charAt(userText.length()) yields 'y'. CHALLENGE ACTIVITY 6.8.1: Looking for characters. Write an expression to detect that the ±rst character of userInput matches ±rstLetter. System . out . print ( name . charAt ( 0 )) ; System . out . print ( name . charAt ( 1 )) ; System . out . print ( name . charAt ( 2 )) ; System . out . println ( name . charAt ( 3 )) ; 75 76 77 78 ... A m y name k 79 0 1 2 otherVar Am y out of range EXCEPTION Feedback?
Image of page 5
Image of page 6

You've reached the end of your free preview.

Want to read all 7 pages?

  • Fall '19
  • Dang, 2034, 2 79 k

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture