Chapter 4.3 Characters Flashcards

1
Q

Character definition

A

A character is a single character.
A character literal is enclosed in matching single quotes (‘).
ex.
char letter = ‘A’;
char numChar = ‘4’;

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

ASCII code values in decimal and unicode for characters ‘0’ to ‘9’

A

48-57
\u0030 to \u0039

char numChar = (char)52; // ’4’

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

ASCII code values in decimal and unicode for characters ‘A’ to ‘Z’

A

65-90
\u0041 to \u005A

char letter = (char)65; // ’A’
\

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

ASCII code values in decimal and unicode for characters ‘a’ to ‘z’

A

97-122
\u0061 to \u007A

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

How many bytes does unicode take

What is the range of the highest to lowest unicode value

A

two bytes

‘\u0000’ to ‘\uFFFF’

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

Escape character for Characters: backspace

A

\b
\u0008
8

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

Escape character for Characters: tab

A

\t
\u0009
9

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

Escape character for Characters: linefeed

A

\n
\u000A
10

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

Escape character for Characters: formfeed

A

\f
\u000D
13

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

Escape character for Characters: carriage return

A

\r
\u000D
13

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

Escape character for Characters: backlash

A


\u005C
92

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

Escape character for Characters: double quote

A

"
\u0022
34

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

char ch = ‘a’;
ch++;
System.out.println(ch);

what prints?

A

b

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

How to convert a character to an int type to perform character arithmetic

A

c = (char) (c+1);

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

Given the statement
char x = ‘7’;
then the statement
int i = (int)(x - ‘0’);

what is the value of i

A

will assign to i the value 7 because the difference between the encoding of ‘7’ and the encoding of ‘0’ is 7.

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

‘a’ < ‘b’ true or false

A

//true because the Unicode for ‘a’ (97) is less than the Unicode for ‘b’ (98).

17
Q

‘a’ < ‘A’
t or f

A

//false because the Unicode for ‘a’ (97) is greater than the Unicode for ‘A’ (65).

18
Q

‘1’ < ‘8’
t or f

A

//true because the Unicode for ‘1’ (49) is less than the Unicode for ‘8’ (56).

19
Q

Character method to: return true if the specified character is a digit

A

isDigit(ch)

20
Q

Character method to: return true if the specified character is a letter

A

isLetter(ch)

21
Q

Character method to: return true if the specified character is a letter or digit

A

isLetterOrDigit(ch)

22
Q

Character method to: return true if the specified character is a lowercase letter

A

isLowerCase(ch)

23
Q

Character method to: return true if the specified character is an uppercase letter

A

isUpperCase(ch)

24
Q

Character method to: return the lowercase of the specified character

A

toLowerCase(ch)

25
Q

Character method to: return the uppercase of the specified character

A

toUpperCase(ch)