Key_for_6EExam4_Ch6_

# Key_for_6EExam4_Ch6_ - Key for Exam 4 Part I Multiple...

This preview shows pages 1–3. Sign up to view the full content.

Key for Exam 4 Part I: Multiple Choice Questions: (1 pts each) 1. d 2. d 3. a 4. d 5. d 6. a 7. a 8. a 9. b d 10. a 11. d 12. b Part II. (3 pts) Find and fix all errors in the following program: (A) public class Test { public static void main(String[] args) { double[ 4 ] list = {3, 4, 5, 6.3}; xMethod(list); } public static double xMethod( int double [] list) { for (int i=0; i< = list.length; i++); { sum += list[i]; } return sum; } } (B) high > low should be high >= low Part III: Show the printout of the following code: a. (2 pts each) public class Test { public static void main(String[] args) { 1

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

View Full Document
int[] a = {1, 2}; swap(a[0], a[1]); System.out.println("a[0] = " + a[0] + " a[1] = " + a[1]); } public static void swap(int n1, int n2) { int temp = n1; n1 = n2; n2 = temp; } } a[0] = 1 a[1] = 2 b. (2 pts each) public class Test { public static void main(String[] args) { int[] a = {1, 2}; swap(a); System.out.println("a[0] = " + a[0] + " a[1] = " + a[1]); } public static void swap(int[] a) { int temp = a[0];
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Key_for_6EExam4_Ch6_ - Key for Exam 4 Part I Multiple...

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

View Full Document
Ask a homework question - tutors are online