Which one of the following is the correct code snippet for calculating the largest value in an integer array list aList?
A) int max = 0;
For (int count = 1; count < aList.size() ; count++)
{
If (aList.get(count) > max)
{
Max = aList.get(count) ;
}
}
B) int max = aList.get(0) ;
For (int count = 1; count < aList.size() ; count++)
{
If (aList.get(count) > max)
{
Max = aList.get(count) ;
}
}
C) int max = aList[1];
For (int count = 1; count < aList.size() ; count++)
{
If (aList.get(count) > max)
{
Max = aList.get(count) ;
}
}
D) int max = aList.get(0) ;
For (int count = 1; count > aList.size() ; count++)
{
If (aList.get(count) >= max)
{
Max = aList.get(count) ;
}
}
Correct Answer:
Verified
Q39: Assume the variable numbers has been declared
Q88: Which statement is true about the code
Q89: Assume the following variable has been declared
Q90: What is the output of the following
Q94: Which statement is true about the code
Q95: How many elements can be stored in
Q96: Which one of the following statements is
Q97: Which statement is true about the code
Q106: What should you check for when calculating
Q110: When an integer literal is added to
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents