3.4 What output was generated? ----jGRASP exec: java Example1 Session starting months in 2006: January August ----jGRASP: operation complete. 3.8 What output was generated? same as 3.4 3.9 You might be surprised that Example1 executed given that it uses Constants.FALL which is no longer defined. Why did it execute? The Example1 class had incorporated the constant values into its code. Since we did not recompile Example1, the old value for Fall was used. 3.11 What error was generated? Example1.java:10: cannot find symbol symbol : variable FALL location: class Constants for (int i=Constants.SPRING; i<=Constants.FALL; i++) 3.16 What output was generated? Session starting months in 2006: January August 3.17 What is wrong with this output and what caused the problem? We added the new constant, but the starting month for the Summer is not displayed. 3.21 What output was generated? Session starting months in 2006: January August August 3.22 What is wrong with this output and what caused the problem? The SemesterUtility class looks for the SPRING semester and says that everything else starts in August. 3.24 Will this version of Example1.java compile? Yes 3.25 What output would be generated by this statement? August 3.26 Why is this somewhat troubling? Any integer regardless of whether it represents a semester is accepted. 3.27 What output would be generated by the statement System.out.println(Constants.SPRING); 0 3.28 What output would be more informative for the previous statement? Spring or SPRING 4.3 What output was generated? Grade on first attempt: B- Grade on second attempt: B+ 4.5 What code did you add to the main() method in Example2.java? (Copy and paste it here.) if (second.compareTo(first)) > 0 better = second; else better = first; 4.8 What output was generated? Grade on first attempt: B- Grade on second attempt: B+ Better grade: B- 4.9 What is wrong with this output and why? While lexigraphically B- comes before B+ (and so is a better grade from a String point of view) we know that a B+ is better than a B- in the context of grade meanings. 4.10 How does a "B" compare to a "B-" at JMU and in Java? A B is considered a better grade at JMU, but in java it would be worse. 5.3 What output was generated? Second is better 5.4 What determines the order used by the compareTo() method? The order in the enumerated type definition. 5.5 What class files were generated (missing in original worksheet). Example3$LetterGrade.class Example3.class 5.9 What .class files were generated? Example3.class LetterGrade.class 5.11 What output was generated? Second is better. 5.12 Suppose JMU instituted a grade of "D-". What changes would you need to make to LetterGrade.java? Insert D- between F and D in LetterGrade.java 6.1 Create an enumerated type named Sessions.java that includes a Spring, Summer, and Fall semester (in the appropriate order for a calendar year). public enum Sessions { SPRING, SUMMER, FALL } 6.2 Modify SemesterUtilities.java and Example1.java so that they work correctly with this enumerated type. (Hint: Think about using a "for each" loop.) public class Example1 { public static void main(String[] args) { System.out.println("Session starting months in 2006: "); for (Sessions semester : Sessions.values()) { System.out.println(SemesterUtilities.startingMonth(semester)); } } } public class SemesterUtilities { public static String startingMonth(Sessions semester) { String month; if (semester.equals(Sessions.SPRING)) month = "January"; else if (semester.equals(Sessions.SUMMER)) month = "May"; else if (semester.equals(Sessions.FALL)) month = "August"; else month = "invalid"; return month; } }