1. (i) (a) True (b) False (c) False (d) True 2. The code will not compile (2 marks), because f is not static. 1 mark for "1 , 1", which is what the code would output if f were made static. 3. Note: Thank you to those who have pointed out that the question is ambiguous, we will take this into account when grading. Full marks will be given for a correct answer to one interpretation of the question. (a) public class SimpleAccount extends Account { private double balance; public SimpleAccount(int accountNo, double balance) { super(accountNo); this.balance = balance; } @Override public void deposit(double amount) { balance += amount; } @Override public boolean withdraw(double amount) { if (amount <= balance) { balance -= amount; return true; } else { return false; } } @Override public double getBalance() { return balance; } @Override public void endOfMonth() {} } (b) public class CheckingAccount extends Account { private double balance; private double overdraftLimit; public CheckingAccount(int accountNo, double balance, double overdraftLimit) { super(accountNo); this.balance = balance; this.overdraftLimit = overdraftLimit; } @Override public void deposit(double amount) { balance += amount; } @Override public boolean withdraw(double amount) { if (balance - amount >= -overdraftLimit) { balance -= amount; return true; } else { return false; } } @Override public double getBalance() { return balance; } @Override public void endOfMonth() { balance -= 100; } } (c) public class TransactionAccount extends Account { private double balance; private int transactions; public TransactionAccount(int accountNo, double balance) { super(accountNo); this.balance = balance; transactions = 0; } @Override public void deposit(double amount) { balance += amount; transactions++; if (transactions > 4) { balance -= 50; } } @Override public boolean withdraw(double amount) { if (amount <= balance) { balance -= amount; transactions++; if (transactions > 4) { balance -= 50; } return true; } else { return false; } } @Override public double getBalance() { return balance; } @Override public void endOfMonth() { balance *= 1.003; transactions = 0; } } 4. (a) 11 (b) It outputs the maximum element of a. 5. boolean isLuckyHelper(int p, int k) { if (p <= k) { return true; } if (p % (k + 1) == 0) { return false; } return isLuckyHelper(p - p / (k + 1), k + 1); } boolean isLucky(int n) { return isLuckyHelper(n, 1); } An alternative non-recursive solution: private static boolean isLucky(int n) { boolean[] deleted = new boolean[n+1]; for (int i = 0; i <= n; i++) { deleted[i] = false; } for (int step = 2; step <= n; step++) { // Delete every "step"th number int count = 0; for (int i = 1; i <= n; i++) { // Count step - 1 "false"s, then turn the "step"th false into a true if (! deleted[i]) { count ++; if (count == step) { deleted[i] = true; count = 0; } } } } return ! deleted[n]; } There are many other possible solutions.