D.1.9 Explain the need for different data types to represent data items.
Data type specifies the size and type of values that can be stored in an identifier.
a data type or simply type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data
choose the most appropriate type for the quantity being represented.
If a value could possibly have a decimal portion, then double is the best choice.
If a variable will represent only whole numbers, then int is the best choice even though double will work.
both the compiler and the reader will understand the possible values for a variable.
the compiler allocates the appropriate memory for the variable and therefore preserves the integrity, precision of data
Reference types hold references to objects and provide a means to access those objects stored somewhere in memory. The memory locations are irrelevant to programmers.
There are two type categories in Java: reference types and primitive types.
Consists of boolean and numeric types: char, byte, short, int, long, float, and double.
Memory location stores actual data held by the primitive type.
When a value of a primitive is assigned to another variable of the same type, a copy is made.
When a primitive is passed into a method, only a copy of the primitive is passed. The called method does not have access to the original primitive value and therefore cannot change it. The called method can change the copied value.
Unlimited number of reference types, as they are defined by the user.
Memory location stores a reference to the data.
When a reference type is assigned to another reference type, both will point to the same object
When an object is passed into a method, the called method can change the contents of the object passed to it but not the address of the object.
Primitive Data Types, https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
Data structures and data types, https://www.bbc.co.uk/bitesize/guides/zkq7xfr/revision/1