Use operators to convert 153 minutes to hours and store it in a double variable called 'hours'
What will the following statement print:
String flavor1 = "mint';
String flavor2 = "strawberry";
System.out.println(flavor1 + "chocolate" + flavor2 + "vanilla;");
mintchocolatestrawberryvanilla;
Type out the frame of an if-else statement.
if(condition)
{
//statements
}
else
{
//statements
}
What is wrong with the following code:
boolean isNum = 45;
Wrong datatype; boolean only stores true or false
What is the minimum number of times a while and do-while loop can run?
while = 0 times
do-while = 1 time
What is the "or or" sign?
||
T/F Main is not needed for a program to run.
False
Which statement is executed:
if(4 >= 5){
statement1;
}
else
{
statement2;
}
statement 2
Declare and initialize a string variable that stores the color of a tablet as black.
String color = "black";
What is another difference between while and do-while loops?
while = condition is checked before the loop body
do-while = condition is checked after the loop body is executed
What operator is used to check if multiple conditions evaluate true?
&&
What is a class?
A class is the template that describes the data and behavior associated with everything in that class.
How do you check if the variable 'num' is odd?
if(num % 2 != 0)
{
//statements
}
int difference = ___ - ___;
Type the frame of a do-while loop.
do
{
//statements
} while(condition);
How would you type the condition "num is less than or equal to 11"
num <= 11
Type out the main method
public static void main(String [] args)
{
//statements
}
How would you check if the variable 'num' is less than 5 AND greater than or equal to 1?
if(num < 5 && num >= 1){
//statements
}
T/F String is a primitive data type.
False
Predict the output of the following:
int num = 18;
while(num % 3 == 0 && num > 5){
System.out.println(num);
num = num - 2;
}
18
What will (10 + 5%3 - 4)/2?
4
What will the following statement print:
double money = 32.74;
System.out.printf("%s$%s dollars.", "He has ", money);
He has $32.74 dollars.
What statement is executed:
int num = 345;
if(num == 345 && (num >= 5 || (num % 2 == 0)))
{
//statement2;
}
else
{
//statement1;
}
statement 2
What are the four primitive data types we learned in this class?
int, boolean, double, and char
Predict the output of the following:
int num = 4;
do{
System.out.println(num-1);
num--;
}while(num < 4 && num > 0);
3
2
1
0