Respuesta :
Answer:
The following are the description of the recursive method:
public int recursive(int[] x1, int position) //defining a method recursive
{
if(position<x1.length) //defining if block that checks position value is less then array length
{
if(x1[position]%2==0) //defining if block that checks in array there is even number
{
return 1+recursive(x1, position+1); //use return keyword to call method by incremnent value
}
else//defining else block
{
return recursive(x1, position+1);//use return keyword to call method and add 1 in position value
}
}
else//defining else block
{
return 0;//return value 0
}
}
Explanation:
In the given code, a recursive method is declared, that accepts two integer variable "x1 and position", in which "x1" is an array variable, that pass in the function parameter.
In the method, the if block is used that checks the position values is less then array length. Inside this another, if block is used, that checks in the array there is an even number.
In the condition is true, it will call the method by adding the 1. otherwise, go to the else block, in this, it will call the method and add 1 in position variable.
if the above condition is false, it will go to else block and return a value, that is "0".