Chapter 1 - Objects and classes Flashcards
when naming these they always begin with a lower case letter
what is the convention for naming
objects
describe a
class
is a category or type of something that will have characteristics
an object is an instance of a class
describe an
instance
these include
* byte (1 byte)
* short (2 bytes)
* int (4 bytes)
* long (8 bytes)
what are the 4
integer primitive types
and their size in bytes
these include
* float (4 bytes)
* double (8 bytes)
what are the 2
real number primitive types
and their size in bytes
describe in 3 points javas
object type
- these are created by the user
- when held in a variable only a reference to the original is stored, a copy of the variable will also reference the same original
- changes made to any reference will be reflected on all references
this is the act of converting a smaller type to a larger type size
byte -> short -> char -> int -> long -> float -> double
describe
widening casting
and the order of types
this is the act of having many instances from a single class. Each instance is an object that can change its state by adjusting the values of its fields
describe
multiple instances
double myDouble = 9.78d;
int myInt = (int) myDouble; // Manual casting: double to int
manually cast a double to an int
what is type casting
this is when you assign a value of one primitive data type to another type.
is a category or type of something that will have characteristics
describe a
class
manually cast a double to an int
double myDouble = 9.78d;
int myInt = (int) myDouble; // Manual casting: double to int
describe in 3 points javas
primitive data types
- these are predefined data types of Java. They specify the size and type of any standard values
- these are not associated with classes and so have no methods
- when this is declared in a variable it is stored directly, if the variable is copied then another copy is created
describe an
object
is a specific entity of a class that will have the characteristics of its class but will be specific to this object
- these are created by the user
- when held in a variable only a reference to the original is stored, a copy of the variable will also reference the same original
- changes made to any reference will be reflected on all references
describe in 3 points javas
object type