1. {7,5}. For a general array 'process' will swap the first two elements in the array 2. import java.util.*; public class Question2 { public static boolean isPalindrome(char[] a) { for (int i = 0; i < a.length/2; i++) { if (a[i] != a[a.length-i-1]) return false; } return true; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); System.out.println(isPalindrome(s.toCharArray())); } } 3. public static List nub(List list) { List copy = new ArrayList(); for (int i = 0; i < list.size(); i++) { Object elem = list.get(i); boolean found = false; for (int j = 0; j < copy.size(); j++) { if (elem.equals(copy.get(j))) { // Here you can choose to use ==. // The question is not explicit. found = true; break; } } if (!found) copy.add(elem); } return copy; } 4. public class Game { private boolean[] state; public Game(int n) { state = new boolean[n]; for (int i = 0; i < n; i++) { state[i] = (Math.random() > 0.5); } } public void step() { boolean[] new_state = new boolean[state.length]; for (int i = 1; i < state.length-1; i++) { if (state[i-1] == state[i] && state[i] == state[i+1]) { new_state[i] = !state[i]; } else { new_state[i] = state[i]; } } state = new_state; } public void print() { for (int i = 0; i < state.length; i++) { if (state[i]) System.out.print('*'); else System.out.print(' '); } System.out.println(); } }