In an array which notation below indicates the last element
In an array, which notation below indicates the last element of the array? arrayName[arrayName.length = 1] arrayName[arryName.length] arrayName[arryName.length + 1] None of the above. After the code below executes, what will be in the last line? (Assume all variables are properly declared and initialized.) The lowest value in the array. The highest value in the array. None of the above. for (int I = 1; i teamRoster[templndex]) templndex = i;} System out println(teamRoster[templndex]);
Solution
question 19:
arrayName[arrayName.length - 1];
question 20:
the highest value of array.
How? . see this example:
public class HelloWorld{
public static void main(String []args){
int teamRoster[] = {1,5,9,6,3,2};
int tempIndex = 0;
// loop from 1 to tempIndex length
for(int i = 1 ; i < teamRoster.length ; i++ )
{
//check if current tempIndex value is lesser then i index value
if(teamRoster[i] > teamRoster[tempIndex])
{
tempIndex = i;
}
}
System.out.println(teamRoster[tempIndex]);
}
}
Output:
9
![In an array, which notation below indicates the last element of the array? arrayName[arrayName.length = 1] arrayName[arryName.length] arrayName[arryName.length In an array, which notation below indicates the last element of the array? arrayName[arrayName.length = 1] arrayName[arryName.length] arrayName[arryName.length](/WebImages/36/in-an-array-which-notation-below-indicates-the-last-element-1108382-1761587118-0.webp)