1. Given the following code, it is always legal (okay and permissible) to use a negative number like so: data [-1]
2. What is the output of the following code?
3. What is the output of the following code?
4. Only use the for-each loop when you want to loop through all the values in an array or list. If you only want to loop through part of an array or list use a for loop instead.
5. For-each loops access all elements and enable users to use a variable name to refer to array elements.
6. For-each loops also allow users to modify elements directly.
7. Analyse the code below, and fill in the blanks. Since ______ is an object field and the method getAverage is in the same class it can directly access the field ________.
8. Referring to the code above, the code could have also been written as ____________ to indicate the current object?s field called values.
9. Given that x is an array of integers and val is an integer value, which of the following best describes the conditions under which the following code segment will return true?
10. In the above example, there is no count of the number of times the array element is equal to val.
11. Given the following field and method, which of the following best describes the contents of myTrack after (int m = mystery(n);) has been executed?
12. Referring to the code above, mystery loops forward through the array and returns when it finds a value greater than the passed num (n).
13. Refer to the code below and decide whether this statement is true or false. Whenever a has values larger then temp, an infinite loop is caused.
14. Again, referring to the above code, whenever a includes a value equal to temp, an infinite loop is caused.
15. Refer to the code in question 13: Whenever a includes a value that is less than or equal to zero, an infinite loop is caused.