Assignments Flashcards

1
Q

Describe the two types of memory that are used by Java?

A

The stack and the heap.

Instance variables and objects live on the heap, and local variables live on the stack along with method calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the 4 different ways to represent integer types

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe what change has been introduced in Java 7 which allows for better readability for integer values?

A

Underscores.

  • They can appear anywhere except the first character and last character.
  • Cannot appear next to the decimal point.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the default primitive type for all floating point types?

A

Double. If you specify a F or f at the end then it will be cast to a floating point type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly