CPSC 2150 - DAY 11 SEPTEMBER 29, 2016 ================================================================================== Exam 1 Question Review ---------------------- No Run time errors (on this test at least)! int i = 12L Compile-time Error int i = 1000; byte j = (byte)i; No Error! short s = 10; Short t = s; No Error! bool b = true; int i = (int)b; Compile-time Error static final int i = 22; i++; i--; Compile-time Error /** *@requires 0 <= low <= high < a.length; * *@ensures isPresent returns true iff x is in a between low and high */ public static boolean isPresent(int x, int low, int high, int[] a) {...} What changes would you make to the contract if you want to use binary search? (Requires that a is sorted) public Person (int x) { age = x; if(age >= 18) isVoting = true; } public void getOlderByOne() { age++; if(age >=18) isVoting = true; } void getOlderQuickly(Person p, int inc) { for(int i = 0; i < inc; i++) { p.getOlderByOne(); } } void agingPersons () { Person p = new Person(); Person q = new Person(10); Person r = new Person(20); getOlderQuickly(p,10); if(p == q) getOlderQuickly(q,10); p = r; getOlderQuickly(p,10); } p = 30 q = 10 r = 30 IPerson p = new IPerson(); comp error IPerson q = new Person1(); Person2 r = new Person2(); r = q; comp error IPerson q = new Person2(); Person2 r = new Person2(); r = q comp error