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

Method Analysis With Nested Loops

Mark
< Prev
Next >

Consider the findSomething method below. Assume that arrays a and b have the same length.

public static boolean findSomething(int[] a, int[] b) {
 for (int aValue: a) {
  boolean found = false;
  for (int bValue: b) {
   if (bValue == aValue)
    found = true;
  }
  if (!found)
   return false;
 }
 return true;
}

The findSomething method returns true if and only if which of the following is true?

A

array a contains at least one element that is also in b.

B

arrays a and b contain identical elements in the same order.

C

arrays a and b contain identical elements in reverse order.

D

every element of array a is also in b.

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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