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
}
```
You might also like to view...
Define hard disk quotas, and then explain how they are used. Then, describe the differences between soft limits and hard limits.
What will be an ideal response?
George is concerned that his children might somehow be exposed to things on the Internet that they are not mature enough to handle. He wants a way to limit their ability to view content on the Internet. What will you recommend to George?
A. Use a firewall. B. Use Parental Controls. C. Use port forwarding. D. Use WPA2.