When a Java method is passed an array as a parameter how doe
When a Java method is passed an array as a parameter, how does the method know how many elements the array has? (Points : 6) The method can use the length member of the array object to find out the number of elements. The size of the array must be passed as a separate parameter to the method. The method can simply ask the user for the size of the array. The method has no way of knowing since it did not create the array.
Solution
1)Yes the method can use length member of the array object to find out the number of elements
 eg:
 public int methodOf(int[ ] array, int value) {
 for (int i = 0; i < array.length; i++) {
 }
 }
2)or we can pass the length of the array as an argument
public int methodOf(int[ ] array,int length, int value) {
 }
3)or we can ask the user to enter the array size with in the method

