Name: ___________________________

Practice Test 2 (COP 2510)

1) Consider the following code that will assign a letter grade of ‘A’, ‘B’, ‘C’, ‘D’, or ‘F’ depending on a student’s test score. if (score >= 90) grade = 'A'; if (score >= 80) grade = 'B'; if (score >= 70) grade = 'C'; if (score >= 60) grade = 'D'; else grade = ‘F’; a) This code will work correctly in all cases b) This code will work correctly only if grade >= 60 c) This code will work correctly only if grade < 60 d) This code will work correctly only if grade < 70 e) This code will not work correctly under any circumstances Answer_____________________

2) What is the output of the following code: int x = 9; int y = 8; int z = 7; if (x > 9) if (y > 8) System.out.println("x > 9 and y > 8"); else if (z >= 7) System.out.println("x = 7"); else System.out.println("x