Type Conversion Flashcards

1
Q

Types of data types?

A

Implicit and explicit

> > NEED COMPATIBLE DATA TYPES, str + int = error

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

Implicit data conversion

A

Value of data type with smaller range is assigned to variable of compatible type with larger range

I.e int -> double

Byte -> short -> int -> long -> float -> double
^
|
Char

Int to float, doesn’t need f for float.

Automatically done

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

Explicit data type conversion

A

Convert larger data type to a smaller range. This can’t be done by compiler implicitly as a possibility of data loss

I.e.
double price = 200;
Int newPrice = (int)price;

Not done automatically

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