Easy Multiple Choice QuestionsΒΆ

These problems are easier than most of those that you will usually see on the AP CS A exam.

5-7-1: What does the following code print when x has been set to 187?

if (x < 0) System.out.println("x is negative");
else if (x == 0) System.out.println("x is zero");
else System.out.println("x is positive");




5-7-2: What is printed when the following code executes and x equals 4 and y equals 3?

if (!(x < 3 || y > 2)) System.out.println("first case");
else System.out.println("second case");



5-7-3: What is the value of grade when the following code executes and score is 80?

if (score >= 90) grade = "A";
if (score >= 80) grade = "B";
if (score >= 70) grade = "C";
if (score >= 60) grade = "D";
else grade = "E";






5-7-4: What is printed when the following code executes and x has been set to zero?

if (x > 0 || (y / x) == 3) System.out.println("first case");
else System.out.println("second case");