Assignments Flashcards
Describe the two types of memory that are used by Java?
The stack and the heap.
Instance variables and objects live on the heap, and local variables live on the stack along with method calls.
Name the 4 different ways to represent integer types
decimal (base 10), hexidecimal (base 16, starts with 0x or 0X and is not case sensitive), binary (base 2, starts with 0b or 0B) and octal (base 8, starts with 0) These are stored in bytes (8 bits), shorts (16 bits), ints (32 bits) and long (64 bits).
All 4 integer literals are defined as ints by default (stored in 32 bits) but could be stored in longs by placing a l or L at the end of the literal.
Describe what change has been introduced in Java 7 which allows for better readability for integer values?
Underscores.
- They can appear anywhere except the first character and last character.
- Cannot appear next to the decimal point.
What is the default primitive type for all floating point types?
Double. If you specify a F or f at the end then it will be cast to a floating point type