Unit 2 Reviewing the Basics
The equal to relational operator is ____________. - "==" - "=" - "!=" - "!!"
"="
In Java, what is the value of 3 + 7 * 4 + 2? - 33 - 48 - 21 - 42
33
A boolean variable can hold any character. True or False
False
The assignment operator in Java is == True or False
False
Which Java statement produces w on one line and xyz on the next line? - System.out.println("w" + "xyz"); - System.out.println("w\nx\ny\nz"); - System.out.println("w\nxyz"); - System.out.println("wxyz");
System.out.println("w\nxyz");
The value 137.68 can be held by a variable of type float. True or False
True
You use a type cast to explicitly override an implicit type. True or False
True
Which assignment is correct in Java? - double money = 12.0d; - double money = 12.0; - double money = 12; - all of the above
all of the above
Which of the following elements is not required in a variable declaration? - an assigned value - a type - a semicolon - an identifier
an assigned value
An escape sequence always begins with a(n) ____________. - backslash - forward slash - e - equal sign
backlash
Which of the following data types can store the value 0 using the least amount of memory? - byte - short - long - int
byte
Which assignment is correct in Java? Two of these are correct char aChar = '*'; char aChar = 5.5; char aChar = "W";
char aChar = '*';
When data cannot be changed after a class is compiled, the data is ____________. - variable - mutable - constant - volatile
constant
Which assignment is correct in Java? - int value = (float) 4.5; - float value = 4 (double); - char value = 5c; - double value = 2.12;
double value = 2.12;
If you attempt to add a float, an int, and a byte, the result will be a(n) ____________. - error message - int - float - byte
float
When you perform arithmetic with values of diverse types, Java ____________. - requires you to explicitly convert the values to a unifying type - issues an error message - implicitly converts the values to a unifying type - implicitly converts the values to the type of the first operand
implicitly converts the values to a unifying type
The remainder operator ____________. - provides the quotient of integer division - must follow a division operation - is represented by a forward slash - is represented by %
is represented by %
Which of the following is not a primitive data type in Java? - boolean - int - byte - sector
sector
Assuming you have declared shoeSize to be a variable of type int, which of the following is a valid assignment statement in Java? - shoeSize = 9; - shoeSize = 9.5; - shoeSize = "nine"; - Two of the above are valid.
shoeSize = 9;
According to the rules of operator precedence, when division occurs in the same arithmetic statement as ____________, the division operation always takes place first. - multiplication - remainder - subtraction - Answers a and b are correct.
subtraction