Chapter II Flashcards

Working with java primitive data types and string APIs Describing and using objects and classes

1
Q

Primitive type

A
boolean 
byte
short
int
long
float
double
char
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

boolean

A

true or false

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

byte

A

8-bit integral value - 123 → Stores whole numbers from -128 to 127

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

short

A

16-bit integral value - 123 → Stores whole numbers from -32,768 to 32,767

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

int

A

32-bit integral value - 123 →Stores whole numbers from -2,147,483,648 to 2,147,483,647

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

long

A

64-bit integral value -123L → Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

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

float

A

32-bit floating-point value - 123.45f →Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits

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

double

A

64-bit floating-point value - 123.456 →Stores fractional numbers. Sufficient for storing 15 decimal digits

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

char

A

16-bit Unicode value - ‘a’

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

Conventions

A
Method and variable names are written in camelCase with the first letter being lowercase
Class and interface names are written in camelCase with the first letter being uppercase. Also, don’t start any class name with $, as the compiler uses this symbol for some files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

var

A
A var is used as a local variable in a constructor, method, or initializer block.
A var cannot be used in constructor parameters, method parameters, instance variables, or class variables.
A var is always initialized on the same line (or statement) where it is declared.
The value of a var can change, but the type cannot.
A var cannot be initialized with a null value without a type.
A var is not permitted in a multiple variable declaration.
A var is a reserved type name but not a reserved word, meaning it can be used as an identifier except as a class, interface, or enum name.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Local variables scope

A

In scope from declaration to end of block

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

Instance variables

A

In scope from declaration until object eligible for garbage collection. (field of objects)

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

Class variables

A

In scope from declaration until program ends. (static variables)

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

Object is not longer reachable when

A

The object no longer has any references pointing to it.

All references to the object have gone out of scope.

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

finalize() how many time can run

A

Can run zero or one times. It cannot run twice