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 comment in Visual Basic begins with:

a) */ b) ' c) // d) \\

Computer Science & Information Technology

Which constants are used to indicate that a ResultSet is scrollable, insensitive to changes and read only?

a. TYPE_SCROLLABLE_INSENSITIVE, CONCUR_READ_ONLY. b. TYPE_SCROLLABLEINSENSITIVE, CONCUR_READONLY. c. TYPE_SCROLL_INSENSITIVE, CONCUR_READ_ONLY. d. TYPE_SCROLL_INSENSITIVE, CONCUR_READONLY.

Computer Science & Information Technology

The Menu bar sits at the top of the workspace and includes several menus.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A field in the Group By field list can refer to any field in a table except the ________ data types

A) OLE Object and Attachment B) Memo and Hyperlink C) OLE Object and Memo D) Attachment and Hyperlink

Computer Science & Information Technology