Questions 1 10Solution1 How would you increment the fourth e
Solution
1. How would you increment the fourth element in the array by one?
d. a[3]++; The array index starts with 0, and accessing the elements can be done by filling the subscript with relavent values.
2. What does the string method indexOf() do?
a. Returns the location of a certain character in the String object.
3. Which statement correctly prints the last character in the string str?
d. System.out.println(str.charAt(str.length()-1)); str.length() will return the length of the string, and charAt will return the character at the specified index.
4. Given that P comes before p in dictionary order, which of the following is true?
d. !(s1.equals(s2) && s3.compareTo(s2) < 0). s1.equals(s2) is false, and when false is && with another value will result in false. And the negation of false is true.
5. The index of the last element of an array is: c. .length - 1. length will return the size of the array, and length - 1 points to the last element in the array.
![Questions 1- 10Solution1. How would you increment the fourth element in the array by one? d. a[3]++; The array index starts with 0, and accessing the elements c Questions 1- 10Solution1. How would you increment the fourth element in the array by one? d. a[3]++; The array index starts with 0, and accessing the elements c](/WebImages/1/questions-1-10solution1-how-would-you-increment-the-fourth-e-966473-1761495056-0.webp)