Sequential Practice

Question 1 of 2

public static int foo(int\[\] arr, int x) {

for(int i = 0; i < arr.length; i++) {

if(arr\[i\] == x) {

return i;

}

}

return -1;

}

Given the method defined above, how many times is the word "Indubitably!" output by the code below?

int\[\] vals = {1,4,51,3,14,91,130,14};

for(int i = 0; i < 20; i++) {

if(foo(vals,i%4) < 0) {

System.out.println("Indubitably!");

}

}