Which datatype has only two values (true and false)?
boolean
How should you name a variable in Java?
lowerCamelCase
What is a constant?
A value that cannot be changed later on in the program.
- single-line comments
- multi-line comments
- JavaDoc comments
What is the result of 7/5 in Java?
1
Which integer datatype provides the least accuracy?
byte
What is the problem with this variable name?
x
How do you indicate that something is a constant?
With the reserved word "final" before the datatype in its declaration.
Which type of comment is indicated by /* and */?
Multi-line comment
What is the result of 9.0/2 in Java?
What floating point datatype provides the most accuracy?
double
What is the problem with this variable name?
cans per pack
Variable names should not have a space, in order to separate words, you should use lowerCamelCase
How should you name a constant in Java?
UPPER_CASE_WITH_UNDER_SCORES
What type of comment is indicated by //?
What are the two types of casting?
- explicit casting, must use (datatype) to cast
- implicit or up-casting
Name an example of a non-primitive datatype?
- string
- array
- object
What is needed for a variable declaration?
- datatype
- variable name
What is convenient about using the same constant in multiple locations in your program?
If you change the value of the constant, places where you used the constant's name will not need to be updated.
What type of comment is indicated by /** and */?
What may happen if you store a value as a datatype that does not have enough accuracy for your value?
Overflow error
What is the difference between a primitive and non-primitive datatype?
- Non-primitive datatypes are classes and object-oriented
What is needed to initialize/assign a variable?
- variable name
- value
When should you use a constant?
When you are going to use a literal value in your program that others may not understand the significance of.
Name a place where it would be best practice to place a comment.
- beginning of file/class
- beginning of method
- explanation for anything with an unclear name
What is a common error that can occur with floating point numbers?
Roundoff error due to values being stored in binary