Public class myprogram public void start int a 2 int

This preview shows page 14 - 20 out of 20 pages.

public class MyProgram { public void start() { int a = 2; int b = 3; a = first(a, b); b = first(b, a); System.out.println(a + " " + b); } private int first(int a, int b) { System.out.println(a + " " + b); a = a + 1; b = b - 1; return b * a; } } (7 marks)
Image of page 14

Subscribe to view the full document.

Question/Answer Sheet - Page 15 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... CONTINUED Question 7 (7 marks) What is the output of the following program? public class MyProgram { public void start() { int[] y = {0, 1}; int z = 1; changeArray(y); changeValue(z); System.out.println(y[0] + " " + y[1] + " " + z); } private void changeArray(int[] a) { a[0] = a[0] + 1; a[1] = a[1] + 1; System.out.println(a[0] + " " + a[1]); } private void changeValue(int a) { a = a + 1; System.out.println(a); } } (7 marks)
Image of page 15