177 % 100 % 10 /2
What is 3?
What is the value of n after the code is executed?
int n = 3;
int m = n;
n--;
m++;
What is n = 2?
Casting int into a double adds a decimal
True
What does Math.PI return?
What is the value of Pi (estimated)?
What is the % symbol called?
What is mod or modulus?
89 % ( 5 + 5 ) % 5
What is 4?
What is the value of m after the code is executed?
int n = 3;
int m = n;
n--;
m++;
Truncation is rounding
What is False?
Truncation only cuts off the decimal place of a number
What will Math.pow(a,b) return?
What is ab?
What does != mean?
What is not equal to?
(double) (27/7) where 27 and 7 are ints
What is 3.0?
double x = 4.0 / 8.0;
int y = 4 / 8;
double ans = x + y;
System.out.println(ans);
What is 0.5?
A Scanner is a method
What is False?
A Scanner is an object
What will Math.random() return?
What is a random double between 0 and 1?
System.out.println and System.out.print are different for what reason?
What is println adds a line but print doesn't?
println outputs text, sends cursor to next line
print outputs text, keeps cursor on same line
Math.pow( (5-2), 3)
What is 27.0?
int x = 4;
int y = 5;
double z = 0.5;
String word = “cheese”;
System.out.println(x+y+word);
What is 9cheese?
There are 8 primitive types in Java
What is True?
(boolean, char, byte, short, int, long, float, double)
What will Math.max(x,y) return?
What is the higher value of x and y?
A variable MUST start with what?
What is a letter or a $?
(1-9) % 3
What is -2?
System.out.println((int)(Math.abs(-1) * Math.sqrt(9)));
What is 3?
Math.abs(-1) will return 1 and when multiplied by Math.sqrt(9) which is 3.0, the answer will be 3, which is casted into an int, so 3.
While loops are the same as do while loops
What is False?
While loops check for the condition BEFORE executing the code but do while loops check the condition AFTER executing the code for the first time
How do you have Math.random() choose a double between 1.0 and 10.0?
What is multiply Math.random() by 9 and add 1?
Math.random() chooses a double from 0.0 to 1.0 so if we multiply by 9 it will choose from 0.0 to 9.0. We then add 1 so that it chooses from 1.0 to 10.0.
What is the main method?
public static void main(String [] args) {}
you should try to memorize this one :)