If-Else Quiz
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
10 Questions
1 point
1
Question 1
1.
What is output by the code below?int b = 100;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = 100;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 2
2.
What is output by the code below?int a = 75, b = 100;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 75, b = 100;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 3
3.
What is output by the code below?int a = 105, b = 120;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 105, b = 120;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 4
4.
What is output by the code below?int a = 105, b = 40;if( a > 90) if( b > 100) out.print("go"); else if( b > 90) out.print("it"); else out.print("up");out.print("on");
What is output by the code below?
int a = 105, b = 40;
if( a > 90)
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 5
5.
What values will be stored in c and d after execution of the following program segment?int c = 5, d = 10;if(d>c){ if(c > 50) c /= 2; else c = d-c; d = d/5;}else{ c = c/2; d = d/2+3;}
What values will be stored in c and d after execution of the following program segment?
int c = 5, d = 10;
if(d>c){
if(c > 50)
c /= 2;
else
c = d-c;
d = d/5;
}
else{
c = c/2;
d = d/2+3;
}
1 point
1
Question 6
6.
What values will be stored in c and d after execution of the following program segment?int c = 12, d = 3;if(d>c){ if(c > 50) c /= 2; else c = d-c; d = d/5;}else{ c = c/2; d = d/2+3;}
What values will be stored in c and d after execution of the following program segment?
int c = 12, d = 3;
if(d>c){
if(c > 50)
c /= 2;
else
c = d-c;
d = d/5;
}
else{
c = c/2;
d = d/2+3;
}
1 point
1
Question 7
7.
What is output by the code below?
int j = 11/2;switch(j){ case 5:j++;break; case 6:j++;break; case 7:j++;break;}System.out.println(j);
What is output by the code below?
int j = 11/2;
switch(j)
{
case 5:j++;break;
case 6:j++;break;
case 7:j++;break;
}
System.out.println(j);
1 point
1
Question 8
8.
What is output by the code below?int x= 11;switch( x ){ case 11 : System.out.print("it"); case 21 : System.out.print("go"); case 98 : System.out.print("up"); break;}
What is output by the code below?
int x= 11;
switch( x )
{
case 11 : System.out.print("it");
case 21 : System.out.print("go");
case 98 : System.out.print("up"); break;
}
1 point
1
Question 9
9.
What is output by the code below?
int b = 110;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = 110;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");
1 point
1
Question 10
10.
What is output by the code below?int b = -5;if( b > 100) out.print("go");else if( b > 90) out.print("it");else out.print("up");out.print("on");
What is output by the code below?
int b = -5;
if( b > 100)
out.print("go");
else if( b > 90)
out.print("it");
else
out.print("up");
out.print("on");