One-page version suitable for printing.
Suppose we were to execute the run() method of the following program. What would it print?
import csbsju.cs160.*; public class Test { public static void f(int x, int[] a) { x = 2; a[0] = 5; } public static void run() { int y = 3; int[] b = { 4 }; f(y, b); IO.println(y + " " + b[0]); } }
Say the user runs the following program, typing 4 when told. What does the program print?
import csbsju.cs160.*; public class Example { public static void main(String[] args) { IO.print("Type something. "); switch(IO.readInt() / 2) { case 0: IO.println("0"); case 1: IO.println("1"); case 2: IO.println("2"); case 3: IO.println("3"); case 4: IO.println("4"); case 5: IO.println("5"); } } }