Java Data Types Flashcards
What is a variable?
A storage location in RAM
What 2 things must a variable have?
A name and a data type
What are 3 other words for variable “name”?
1) Identifier
2) Reference
3) Handle
What are we doing when we declare a variable?
Binding the name to a specific memory address
What can you NOT start a variable name with?
Number
What three things can you start a variable name with?
1) Letter
2) Underscore
3) $
What words can you not use for naming variables?
Java Reserved Words
What kind of notation is used for naming variables?
camelBack
What notation is used for naming classes?
TitleCase
Why do we specify data type when declaring variables?
Tells OS how many bytes of memory to allocate and helps interpret data.
How many characters are shared between ASCII and Unicode?
256
Primitive data types are the only things in Java that are not _______. Why?
Objects, because they have no methods.
How many primitive data types are there?
8
How many numeric primitive data types are there?
6
How many bits in a byte data type?
8 (1 byte)
How many bits in a short?
16 (2 bytes)
How many bits in an int?
32 (4 bytes)
How many bits in a long?
64 (8 bytes)
How many floating primitive types are there?
Two, float and double.
How many bits in a float?
32 (4 bytes)
How many bits in a double?
64 (8 bytes)
What are the two non-numeric data types?
char and boolean
How many bits in the char data type?
16 (2 bytes)
What are the two default numeric primitive data types?
int and double
How are floating numbers stored in Java?
A mantissa and an exponent
What data type is a String?
Object
What is the naming convention for constants?
UPPER_CASE_LETTERS
What keyword is used when declaring a constant?
final
What is a data literal?
The actual data value that appears in a program.
ex. ‘A’, or “Hello World”
How do you get Java to interpret a very long number properly?
Add an ‘L’ to the end of it.
When dividing integers by integers, Java ______ the answer.
Truncates
Which operator returns the remainder from division?
Modulus (%)
What are the unary operators?
(+ and -), denoting positive and negative
What is the increment operator?
++
When do you need to explicitly use type casting?
When assigning a larger data type to a variable with less capacity.
ex. assigning type int data to a variable of short.
What is type casting?
Converts a value of one data type into a value of another data type.
What is a common error of type casting?
Overflow