Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Data Collections
Start Practice TestPractice Test
About Exam
medium Solved by 2 students

Array Minimum Value Initialization

Mark
< Prev
Next >

The findMin method below is intended to return the smallest value in an integer array. Assume the array arr is not empty.

public static int findMin(int[] arr)
{
  int min = /* some value */;
  int index = 0; 
  while (index < arr.length){
    if (arr[index] < min)
      min = arr[index];
    index++;
  } 
  return min;
}

Which of the following can replace /* some value */ to ensure the method always correctly finds the minimum value?

I. Integer.MIN_VALUE

II. Integer.MAX_VALUE

III. arr[0]

A

I only

B

II only

C

III only

D

II and III only

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1hiboyshello22 - 200
#2hridaansingal.17411 - 100
#3michael.2103ll01 - -10
#4kwakmk09033001 - -10
#5test111101 0m 03s -13
#6mlhkrds01 0m 05s -15
Items per page:
10
1 – 6 of 6
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|