COSC 1437 Midterm Exam Questions
and Answers10
What is the result of the following expression?
17 % 3 * 2 - 12 + 15 - ANSWERS-7
What is the result of the following expression?
10 + 5 * 3 - 20 - ANSWERS-5
What is the value of z after the following statements have been executed?
int x = 4, y = 33;
double z;
z = (double)(y/x); - ANSWERS-8.0
What would be displayed as a result of the following code?
int x = 578;
System.uot.print("There are" +
x + 5 + "\n" +
"hens in the hen house."); - ANSWERS-There are 5785 hens in the hen house
What does this code print?
int x = 9;
int y = x++;
System.out.print(( ++x ) = " " + y); - ANSWERS-11 9
, If the following Java statements are executed, what will be displayed?
System.out.print( "The top three
winners are\n");
System.out.print( "Jody, the
Giant\n");
System.out.print("Buffy, the
Barbarian");
System.out.println("Adelle, the
Alligator"); - ANSWERS-The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
What value will be in a after the following code segment is executed?
int a = 5 + 9 % 3;
int b = a;
int c + 1 + b--; - ANSWERS-5
Which of the following is a valid Java literal?
double, 'y', no, x - ANSWERS-'y'
What does this code print?
int b = 5;
System.out.println(b++); - ANSWERS-5
Which of the following statements determines whether the variable temp is within the range of
0 through 100 (inclusive)? - ANSWERS-if (temp >= 0 && temp <= 100)
and Answers10
What is the result of the following expression?
17 % 3 * 2 - 12 + 15 - ANSWERS-7
What is the result of the following expression?
10 + 5 * 3 - 20 - ANSWERS-5
What is the value of z after the following statements have been executed?
int x = 4, y = 33;
double z;
z = (double)(y/x); - ANSWERS-8.0
What would be displayed as a result of the following code?
int x = 578;
System.uot.print("There are" +
x + 5 + "\n" +
"hens in the hen house."); - ANSWERS-There are 5785 hens in the hen house
What does this code print?
int x = 9;
int y = x++;
System.out.print(( ++x ) = " " + y); - ANSWERS-11 9
, If the following Java statements are executed, what will be displayed?
System.out.print( "The top three
winners are\n");
System.out.print( "Jody, the
Giant\n");
System.out.print("Buffy, the
Barbarian");
System.out.println("Adelle, the
Alligator"); - ANSWERS-The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
What value will be in a after the following code segment is executed?
int a = 5 + 9 % 3;
int b = a;
int c + 1 + b--; - ANSWERS-5
Which of the following is a valid Java literal?
double, 'y', no, x - ANSWERS-'y'
What does this code print?
int b = 5;
System.out.println(b++); - ANSWERS-5
Which of the following statements determines whether the variable temp is within the range of
0 through 100 (inclusive)? - ANSWERS-if (temp >= 0 && temp <= 100)