IU Bloomington Evaluation Services and Testing

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); 
Please type your answer in the following box:

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); } 
Please type your answer in the following box:

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); 
Please type your answer in the following box:

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); 
Please type your answer in the following box:

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); 
Please type your answer in the following box:

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); 
Please type your answer in the following box:

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); 
Please type your answer in the following box:

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?

Please type your answer in the following box:

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?

Please type your answer in the following box:

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


Click to submit your answers.   Help


This activity is available between these dates and times: 07.08.10:00-08.11.19:00
It can be submitted a total of 30 times.
If it is a scored activity, the highest non-zero score will be counted.


Screen: TAKE_QUIZ
Last updated: Thu Mar 8 13:40:07 2001
URL: https://www.indiana.edu/~best/cgi-bin/quizsite/students.pl
Comments: best@indiana.edu
Copyright 2000, BEST & The Trustees of Indiana University