Describe int, string, and double variables in your own words.
Int is a whole number.
A string is a combination of words or letters surrounded by quotation marks.
A double variable is a decimal.
Is the third statement true or false?
int x = 15;
int y = 2;
(x * y) == 30;
it is True!
How many times will this code run?
for (int i = 0; i < 5; i++)
5 times
In your own words, describe an array.
Answers may vary.
What is Geronimo Stilton's sister's name?
Thea Stilton
Create an int variable called 'val' with correct syntax as well as a double variable named 'num'.
int val = 1;
double num = 2.5;
Is this True or False? Pay attention to every detail!
int x = 22;
int y = 30;
x - y == 8;
False!
x - y == -8;
How many times will this code run?
for (int i = 10;i > 4; i--)
6 Times
Declare an int, double, and String array.
int [] numbers = {0, 1, 2, 3};
double [] decimals = {2.5, 3.0, 4, 0.0}
String [] array = {“This”, “is”, “an”, “array”};
Values may vary.
Who is Trap Stilton?
Geronimo's Cousin
What is the variable 'a' equal to?
int x = 5;
double y = 4.3;
double a = x + y;
a = 9.3
Write an if statement that prints "Yes" if 15 multiplied by 2 is 30.
if (15 * 2 == 30) {
System.out.println("Yes");
}
Write a for loop that loops 12 times.
for (int i = 0; i <= 12; i++)
for (int i = 0; i < 13; i++)
for (int i = 12; i >= 0; i--)
int [] numbers = {10, -5, 54, 7};
In this array, what value is at index 2?
The number 54.
Who is Harry Potter's best friend?
Ron Weasely
Create and declare a String variable that stores "Java is the best!".
String fav = "Java is the best!";
Is this true or false?
(2 * 3 == 6) && (4 / 1 == 2)
False!
4/1 is 4, not 2!
What will this code output?
for (int i = 0; i <= 4; i++) {
System.out.println(i);
}
0
1
2
3
4
int [] numbers = {0, 1, 2, 3};
Access the 2nd value from this array.
numbers[1];
Who is the Diary of a Wimpy Kid about?
His name is Greg Heffley.
What does this code output?
String word = " awesome!";
int age = 16;
System.out.println("Ayush is " + age + " years old and is extremely" + word);
Ayush is 16 years old and is extremely awesome!
x = 3;
y = 6;
if (y/x == 2 || y - x == 3) {
System.out.println("This is true!");
}
This is true!
What will this code output?
for(int i = 0; i < 5; i++) {
if (i / 2 == 0) {
System.out.println("I is even");
}
}
I is even
I is even
I is even
Find the length of this array using the .length functon.
double [] decimals = {2.5, 3.0, 4, 0.0}
System.out.print(decimals.length;)
What shape is the scar on Harry Potter's forehead?
A lightning bolt.