Type Wrappers - 12,17 Flashcards

1
Q

What are type wrappers?

A

Primitive types like int, double sometimes need object representation to get more functionality.

Can wrap the type in a class/object to get more. e.g.
Double, Integer, Character.

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

what is boxing and unboxing?

A

process of encapsulating a value within an object and visa versa. From primitive types to wrapper objects.

Integer iob = Integer.valueOf(100)

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

make a double thats the numeric value of string “3214”

A

Double d1 = Double.valueOf(“3214”)

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

Covert string to number.

A

String str;
int i;

str = “120”
i = Integer.parseInt(str)

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

explain method in Integer:

static int parseInt (String s)

A

Converts the string s and returns its integer value

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

explain method in Integer

int intValue()

A

returns the value of an Integer object as an int type

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

Explain constructor methods in Integer:

Integer (int n)
Integer (String s)

A

constructs and Integer object form an int type or String type

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

Integer methods list

A

pic

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