Exam 2 Answers 1. a. public class NotLetterException extends Exception { private char c; // Default Constructor public NotLetterException(){ } // Standard constructor public NotLetterException(String s) { super(s); // Call the base constructor } public NotLetterException(String s, char c) { super(s); // Call the base constructor this.c = c; } // Get the char value for the error public char getc() { return c; } } b. static char toUpperCase(char c) throws NotLetterException{ if(Character.isLetter(c)) return Character.toUpperCase(c); throw new NotLetterException("The char is not a letter: ",c); } c. try{ char b = toUpperCase(a); System.out.println("The letter is " + b); } catch(NotLetterException e) { System.out.println(e.getMessage() + e.getc()); } finally { System.out.println("Finished."); } } 2. a. //Create stream output objects. File outFile = new File("backup"); FileOutputStream outStream = new FileOutputStream(outFile); FileChannel outChannel = outStream.getChannel(); ByteBuffer outBuf = ByteBuffer.allocate(1024); //Create physical file. outFile.createNewFile(); b. for(int i = 0; i