WorksheetsJava Lesson 2
Total questions: 7
Worksheet time: 6mins
if(apples are red) System.out.print("Hello"); if(apples are blue) System.out.print("Bye"); __ ____What is the output?______
(a)
How many choices are possible when using a single if-else statement?
1
2
3
4
What does the following output?
int sum = 45;
if ( sum < 20 )
{
System.out.println(Under);
}
else
{
System.out.println(Over);
}
Over
Under
Nothing
Error
there is if, ________ ___, and else statements
(a)
What does the following output?
int sum = 45;
if ( sum < 20 )
{
System.out.println("Under");
}
else
{
System.out.println("Over");
}
Over
Under
Nothing
Compilation error
What is the output?
________________________________________
double grade=102.4
switch(int(grade/10)) {
case 10 :
case 9 :
System.out.println("F");
break;
case 8 : System.out.println("B"); break;
case 7 :
System.out.println("C");
break;
case 6 :
System.out.println("D");
break;
default :
System.out.println("F");
}
return 0;
}
A
B
Prints nothing
F
for(int i=0;i<15; (a) ){
System.out.print(i+" ");
}
If the output is
1 2 3 4 ... 15
what is the missing line?
