Question: Use the method f ( ) below to answer the next 2 questions: public static int f ( int [ ] nums ) { int

Use the method f() below to answer the next 2 questions:
public static int f(int[] nums){
int result =-99;
for (int i =0; i < nums.length; i++){
if (nums[i]==0){
result = i;
}
}
return result;
}
Using the method f() defined above, what will be printed? If you believe the code contains an error, then write ERROR as your answer.
public static void main(String[] args){
int[] a ={15,0,2,7};
System.out.println(f(a));
}
Using the method f() defined above, what will be printed? If you believe the code contains an error, then write ERROR as your answer.
public static void main(String[] args){
int[] b = new int[50];
System.out.println(f(b));
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!