Write a method that accepts an array of integers as a parameter and returns a reference to an array that contains the even numbers in the array original array. The returned array should have a size equal to the number of even numbers in the original array.

What will be an ideal response?

```
public int[] getEvenArray(int[] numbers) {
int size = 0;
for(int i = 0; i < numbers.length; i++)
if(numbers[i]%2 == 0)
size++;

int[] evenArray = new int[size];
int evenArrayIndex = 0;
for(int i = 0; i < numbers.length; i++) {
if(numbers[i]%2 == 0) {
evenArray[evenArrayIndex] = numbers[i];
evenArrayIndex++;
}//end if
}//end for
}
```

Computer Science & Information Technology

You might also like to view...

A combination of characters and symbols can make up an input mask

Indicate whether the statement is true or false

Computer Science & Information Technology

The __________ certification, considered to be one of the most prestigious certifications for security managers and CISOs, recognizes mastery of an internationally identified common body of knowledge (CBK) in InfoSec and is considered to be vendorneutral.

A. CISSP B. GIAC Security Leadership Certification C. Security + D. Associate of (ISC)2

Computer Science & Information Technology