1. In the left column of the following table is a program that contains boolean variable declarations and assignments. Fill in the values of the variables on the right after each line runs. If a variable has not yet been declared, write a question mark (?). If a variable has not yet been initialized, write an asterisk (*). Statement
a
b
boolean a = false; boolean b; b = a == true; a = a != true; a = b || true; b = a && (a || b);
2. Given int a and int b with some value in each of them, explain in your own words: (a) Can (a > b) && (a b) || (a 0); { console.print(“B”); }
11.a Complete the following program such that the values stored at indices 0 and 1 are swapped. This means, after your code runs, whatever the user typed into the first prompt should be stored in a[1] and typed into the second prompt in a[0]. Hint: you will need another variable to accomplish this. char[] a = new char[2]; a[0] = console.promptChar(); a[1] = console.promptChar(); // TODO: Swap the values stored at indices a[0] and a[1]
11.b. Why do you need another variable to accomplish this?