Log in
Sign up for FREE
arrow_back
Library
If-Else Quiz
By Mickey Arnold
star
star
star
star
star
Share
share
Last updated almost 2 years ago
10 questions
Add this activity
1
1
1
1
1
1
1
1
1
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");
itupon
upon
goon
iton
on
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");
upon
on
goon
itupon
iton
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");
itupon
upon
on
iton
goon
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");
itupon
upon
iton
on
goon
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;
}
c = 6 d = 2
c = 6 d = 5
c = 7 d = 1
c = 5 d = 2
c = 6 d = 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;
}
c = 13 d = 3
c = 9 d = 5
c = 7 d = 3
c = 6 d = 4
c = 6 d = 3
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);
7
0
5
6
8
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;
}
itgo
go
it
itgoup
goup
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");
iton
goon
upon
itupon
on
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");
upon
iton
goon
on
itupon