Indiana University Bloomington Evaluation Services and Testing
QuizSite  Students
Quizzes · Tests · Evaluations · Surveys
 Activity: Practice_Two Student: dgerman (Adrian German) Instructor: dgerman Course: J201 Section: 4285
Question 1.
What is the output produced by the following code when embedded in a complete program?
```int x = 3;
if (2 > x)
System.out.print(1);
else
System.out.print(2);
if (x < 2)
System.out.println(3);
System.out.print(4); ```

Note that the program may or may not be indented correctly so think about it carefully.

Question 2.
What is the output produced by the following code when embedded in a complete program?
```int x = 3;
if (2 > x)
System.out.print(1);
else
System.out.print(2);
if (x < 2) {
System.out.println(3);
System.out.print(4); } ```

Note that curly braces have been added to the code from the previous exercise, and the same comment about indentation applies.

Question 3.
What is the output produced by the following code when embedded in a complete program?
```int x = 3;
if (x > 5)
if (x < 10)
System.out.print(1);
else
System.out.print(2);
System.out.print(3); ```

Note that the program may or may not be indented correctly so think about it carefully.

Question 4.
What is the output produced by the following code when embedded in a complete program?
```int x = 3;
if (x > 5) {
if (x < 10)
System.out.print(1); }
else
System.out.print(2);
System.out.print(3); ```

Note that curly braces have been added to the code from the previous exercise, and the same comment about indentation applies.

Question 5.
What is the output produced by the following code when embedded in a complete program?
```if (2 <= 3)
if (0 != 1)
System.out.print(0);
else
System.out.print(1);
System.out.print(2);
if (2 > 3)
if (0 == 1)
System.out.print(3);
else
System.out.print(4);
System.out.print(5); ```

Note that the program may or may not be indented correctly so think about it carefully.

Question 6.
What is the output produced by the following code when embedded in a complete program?
```boolean x;
if (true)
System.out.print(0);
else
System.out.print(1);
x = (1 < 2) && (4 < 3);
if (x)
System.out.print(2);
else
System.out.print(3); ```

Note that the program may or may not be indented correctly so think about it carefully.

Question 7.
What is the output produced by the following code when embedded in a complete program?
```boolean x;
if (true)
System.out.print(3);
else
System.out.print(2);
x = (1 < 2) || (4 < 3);
if (x)
System.out.print(1);
else
System.out.print(0); ```

Note that the program may or may not be indented correctly so think about it carefully.

Question 8.
Consider the program from the previous exercise where the `else` keyword has been erased:
```boolean x;
if (true)
System.out.print(3);
else
System.out.print(2);
x = (1 < 2) || (4 < 3);
if (x)
System.out.print(1);
else
System.out.print(0); ```
What is the program going to output when embedded in a complete program?

Note that the program may or may not be indented correctly now so think about it carefully.

Question 9.
Consider the program from the previous exercise where both `else` keywords have been erased:
```boolean x;
if (true)
System.out.print(3);
else
System.out.print(2);
x = (1 < 2) || (4 < 3);
if (x)
System.out.print(1);
else
System.out.print(0); ```
What is the program going to output when embedded in a complete program?

Note that the program may or may not be indented correctly now so think about it carefully.