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
the car is a class because we cannot answer questions about a particular car
such as
* what colour is the car
* what horse power is the car
why is car a class and not an object
these include
* char (2 bytes)
* boolean (1 bit)
what are the 2
other primitive types
and their size
what are the 2
real number primitive types
and their size in bytes
these include
* float (4 bytes)
* double (8 bytes)
what are the 4
integer primitive types
and their size in bytes
these include
* byte (1 byte)
* short (2 bytes)
* int (4 bytes)
* long (8 bytes)
describe
widening casting
and the order of types
this is the act of converting a smaller type to a larger type size
byte -> short -> char -> int -> long -> float -> double
describe
multiple instances
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
what are the 2
other primitive types
and their size
these include
* char (2 bytes)
* boolean (1 bit)
describe
narrowing casting
and the order of types
this is the act of converting a larger type to a smaller size type
double -> float -> long -> int -> char -> short -> byte
when naming these they always begin with a capital letter
what is the convention for naming classes
is a specific entity of a class that will have the characteristics of its class but will be specific to this object
describe an
object
what are the two types of
casting
in java and how does it occur
this feature includes
* widening casting (occurs automatically)
* narrowing casting (occurs manualy)
what are the two data types found in java
these include
* primitive types
* object types
what is the convention for naming classes
when naming these they always begin with a capital letter
- 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 in 3 points javas
primitive data types
this is when you assign a value of one primitive data type to another type.
what is type casting
this is made up of
fields
and
methods
what is inside an
object
what is inside an
object
this is made up of
fields
and
methods
describe an
instance
an object is an instance of a class
why is car a class and not an object
the car is a class because we cannot answer questions about a particular car
such as
* what colour is the car
* what horse power is the car
this feature includes
* widening casting (occurs automatically)
* narrowing casting (occurs manualy)
what are the two types of
casting
in java and how does it occur
what is the convention for naming
objects
when naming these they always begin with a lower case letter
view link
this is the act of converting a larger type to a smaller size type
double -> float -> long -> int -> char -> short -> byte
describe
narrowing casting
and the order of types
these include
* primitive types
* object types
what are the two data types found in java