Name three different primitive variable types
Any 3 of the following: int, double, char, boolean, float, long, short, byte
What will be the output of the following code: System.out.println((40 + 24)/4);
a. 4
b. 16
c. 20
d. Syntax Error
b. 16
What do these Operators do
+=
-=
*=
/=
preform the chosen operation on a variable
What is the name for adding two strings together
String Concatenation
True or False:
This statement will cause a syntax error
double myDouble = 202;
What will be the output of the following code:
System.out.println( 10 + 30 / 5);
16
What is the full statement to import only the scanner class
java.util.Scanner
What is the operator to get the remainder of a division operation
The Modulus operator %
What is wrong with this statement?
System.out.println("Welcome to " + "my Java Program!)";
the second parenthesis is inside the string.
What is Wrong with this code:
num1 = 30;
System.out.println(num1);
No variable identifier
What will be the Output of the following Code
int num1 = 303%10; System.out.println(num1/10);
0
What is the parameter needed to tell the scanner it will be reading input from the keyboard
What is the keyword for adding an outside package or class to your program
import
What is the output from the following print statement
System.out.println("Welcome to" + "the exam review");
Welcome tothe exam review
Given the statement
int myInt = 50;
How would you create a new variable that is equal to myInt but is a double variable?
double myDouble = (double) myInt
What is one method of rounding a double to two decimal places. (Hint, there is multiple methods)
type cast to int and then divide by 100,
use the Math.round function and then divide by 100
And others
What is the prompt needed to tell a scanner to read the next String?
nextLine
True or false:
you need a semicolon at the end of an import statement?
true
How do you write a print statement that you want to stay on the same line after printing
System.out.print();
What is the difference between Declaration and Initialization?
Declaration is creating a variable and giving it a name whereas Initialization actually assigns that variable a value.
What will be the output of the Following code:
Int number = 250
if(number > 200){
System.out.println(number * 3 / 25)
}
else{
System.out.println(303%30);
}
false because scanner is not capitalized
What does the following code print
int num1 = 202;
int num2 = 35;
num2 += num1;
System.out.println(num1);
202
What is the syntax to print the value of the variable num1?
a. System.out.println("num1");
b. System.out.println(num1);
c. System.out.println(Num1);
d. System.out.println("num1)";
b. System.out.println(num1);