Ifs Quiz

By Mickey Arnold
Last updated 10 months ago
10 Questions

What is the output?
int x = 40;
if( x >= 20 )
out.print("1");
out.print("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");
out.print("2");

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");
}
out.print("2");

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(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(-3) ?
public static String go( int a )
{
if(a>=0)
{
return "1";
}
return "2";
}

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(-9) ?
public static int go( int a )
{
int ans = 0;
if(a>=0)
{
ans += 1;
}
ans += 2;
return ans;
}