What is the only && relationship between two Booleans that results in true?
true && true
In an if-elseif-else chain, how many branches will run?
Exactly one branch will run.
How many times does this loop run?
for (int i = 2; i < 6; i++)
4 times
If a String has length 6, what is its last index?
5
What is the smallest country in the world by land area?
Vatican City
What is the result of: !true || (false && true)?
false
What is printed?
int x = 7;
if (x > 5) System.out.print("A");
if (x > 2) System.out.print("B");
else System.out.print("C");
AB
What is printed?
int i = 1;
while (i < 4) {
System.out.print(i);
i++;
}
123
What does "hello".substring(1,4) return?
"ell"
Which element has the highest melting point of all elements?
Tungsten
Evaluate:
(5 >= 5) && ( 3 < 1 || !(2 != 2) )
true
What is the difference between a single large if-else chain and several individual if statements?
A large if-else chooses only one true branch; several ifs evaluate all conditions independently.
What is the difference between these loops
for (int i = 0; i < 5; i++) { System.out.print(i);}
int i = 0;
while (i < 5) {
System.out.print(i);
i++;
}
They are equivalent! A for loop and a while loop can be the same.
What is returned by: "banana".indexOf("a")?
1
What continent has the most countries?
Africa (54 countries)
What is the result of:
"cat".equals("Cat") || (4 % 2 != 0)?
false
What is printed?
int n = 10;
if (n % 2 == 0)
if (n > 5)
System.out.print("X");
else
System.out.print("Y");
X
What is printed?
for (int r = 0; r < 2; r++) {
for (int c = 0; c < 3; c++) {
System.out.print("*");
}
System.out.println();
}
***
***
What is printed?
String s = "code";
for (int i = 0; i < s.length(); i++) {
System.out.print(s.charAt(i));
}
code
Who was the first woman to win a Nobel Prize?
Marie Curie
Evaluate the full expression:
!(7 > 2 && "hi".length() == 2) || (3 <= 1)
False
!(true && true) || false
!true || false
false || false
false
What is printed?
int a = 4;
if (a < 10)
if (a % 3 == 1)
System.out.print("M");
else
System.out.print("N");
else
System.out.print("P");
M
How many times does the inner loop run total?
for (int r = 0; r < 3; r++) {
for (int c = 2; c <= 6; c += 2) {
// work
}
}
Inner runs 3 times each row → 3×3 = 9 total.
SURPRISE! A question about Random!!!
Create a variable "rangeOfDays" and set it equal to a random number between 225 and 275, inclusive.
int rangeOfDays = (int) (Math.random() * 51 ) + 225;
Which artist holds the record for the most streamed song on Spotify of all time?
The Weeknd (“Blinding Lights”)