quiz12 - { if (data[i] == 0) return true; else return...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Name: ____________________ Section: M N O P Dave's 15-100 April 22, 2009 Quiz 12 Reference: String Class int charAt (int index) Returns the character at the specified index. boolean equals (String anotherString) Returns true if this string has the exact same sequence of characters as the specified string. Otherwise, returns false. int length () Returns the length of this string. 1. Write the value of each of the following expressions: a. '7' - '0' ____________________ b. (char)('v' + 2) ____________________ c. 'a' > 'f' ____________________ d. "quiz".charAt(1) ____________________
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 2. The containsZero method below was written to determine if data contains the value 0 , but it does not always work as intended. public boolean containsZero(int[] data) { for (int i = 0; i < data.length; i++)
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { if (data[i] == 0) return true; else return false; } return false; } For each of the following arrays, circle the value that will be returned by containsZero , as implemented above. Contents of data Array Value Returned By containsZero a. [7, 1, 7] true false b. [0, 2, 4, 4] true false c. [5, 5, 5, 0, 1] true false d. true false e. [3, 5, 0, 3, 0, 9] true false 3 3. Implement a method called count that takes in two parameters--an array of strings, and an integer n--and returns the number of strings in the array that have length n . 4 4. Implement a method called findLowest that takes in a single parameter--an array of double values--and returns the lowest value in the array. You may assume the array is not empty....
View Full Document

Page1 / 4

quiz12 - { if (data[i] == 0) return true; else return...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online