Ifs Quiz
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
10 Questions
1 point
1
Question 1
1.
What is the output?int x = 40;if( x >= 20 ) out.print("1");out.print("2");
What is the output?
int x = 40;
if( x >= 20 )
out.print("1");
out.print("2");
1 point
1
Question 2
2.
What is the output?int a = 40;if(a>=20) out.print("1");if(a>=50) out.print("2");out.print("3");
What is the output?
int a = 40;
if(a>=20)
out.print("1");
if(a>=50)
out.print("2");
out.print("3");
1 point
1
Question 3
3.
What is the output?int a = 40;if(a>=20) out.print("1");out.print("2");
What is the output?
int a = 40;
if(a>=20)
out.print("1");
out.print("2");
1 point
1
Question 4
4.
What is the output?int a = 40;if(a>=50) out.print("1");if(a>=40) out.print("2");out.print("3");
What is the output?
int a = 40;
if(a>=50)
out.print("1");
if(a>=40)
out.print("2");
out.print("3");
1 point
1
Question 5
5.
What is the output?int a = 40;if(a>=50){ out.print("1");}out.print("2");
What is the output?
int a = 40;
if(a>=50)
{
out.print("1");
}
out.print("2");
1 point
1
Question 6
6.
What is returned by the call go(2) ?public static String go( int a ){ if(a>=0) { return "1"; } return "2";}
What is returned by the call go(2) ?
public static String go( int a )
{
if(a>=0)
{
return "1";
}
return "2";
}
1 point
1
Question 7
7.
What is returned by the call go(9) ?public static int go( int a ){ int ans = 0; if(a>=0) { ans += 1; } ans += 2; return ans;}
What is returned by the call go(9) ?
public static int go( int a )
{
int ans = 0;
if(a>=0)
{
ans += 1;
}
ans += 2;
return ans;
}
1 point
1
Question 8
8.
What is returned by the call go(-3) ?public static String go( int a ){ if(a>=0) { return "1"; } return "2";}
What is returned by the call go(-3) ?
public static String go( int a )
{
if(a>=0)
{
return "1";
}
return "2";
}
1 point
1
Question 9
9.
What is returned by the call go(0) ?public static int go( int a ){ int ans = 0; if(a>=0) { ans += 1; } ans += 2; return ans;}
What is returned by the call go(0) ?
public static int go( int a )
{
int ans = 0;
if(a>=0)
{
ans += 1;
}
ans += 2;
return ans;
}
1 point
1
Question 10
10.
What is returned by the call go(-9) ?public static int go( int a ){ int ans = 0; if(a>=0) { ans += 1; } ans += 2; return ans;}
What is returned by the call go(-9) ?
public static int go( int a )
{
int ans = 0;
if(a>=0)
{
ans += 1;
}
ans += 2;
return ans;
}