Chapter 4 Flashcards

1
Q

Which of the following statement prints smith\exam1\test.txt?

A

System.out.println(“smith\exam1\test.txt”);

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

Suppose x is a char variable with a value ‘b’. What is the output of the statement System.out.println(++x)?

A

c

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

To check whether a char variable ch is an uppercase letter, you write ___________.

A

(ch >= ‘A’ && ch <= ‘Z’)

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

[X]Which of the following is not a correct method in the Character class?

	isLetterOrDigit(char)
	isLetter(char)
	toLowerCase(char)
	toUpperCase()
A

toLowerCase(char)

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

The statement System.out.printf(“%3.1f”, 1234.56) outputs ___________.

A

1234.6

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

The __________ method parses a string s to an int value.

A

Integer.parseInt(s); (Capital I in Integer)

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

The statement System.out.printf(“%5d”, 123456) outputs ___________.

A

123456

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

The statement System.out.printf(“%10s”, 123456) outputs ___________. (Note: * represents a space)

A

**123456

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

What is Math.rint(3.5)?

A

4.0

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

What is Math.rint(3.6)?

A

4.0

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

What is the return value of “SELECT”.substring(4, 4)?

A

An empty string

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

“abc”.compareTo(“aba”) returns ___________.

A

2

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

What is the return value of “SELECT”.substring(0, 5)?

A

“SELEC”

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

[X]Note that the Unicode for character A is 65. The expression “A” + 1 evaluates to ________.

A

Illegal expression

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

An int variable can hold __________.

A

120

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

Note that the Unicode for character A is 65. The expression ‘A’ + 1 evaluates to ________.

A

66

17
Q

Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i?

A

System.out.println((char)i);

18
Q
Which of the following assignment statements is correct?
                char c = 'd';
		char c = '100';
		char c = "d";
		char c = "100";
A

char c = ‘d’;

19
Q

Which of the following is the correct expression of character 4?

A

‘4’

20
Q

Which of the following is the correct statement to return JAVA?

A

“Java”.toUpperCase()

21
Q

A Java character is stored in __________.

A

2 bytes

22
Q

The __________ method parses a string s to a double value.

A

Double.parseDouble(s);

23
Q

[X}Will System.out.println((char)4) display 4?

A

no

24
Q

[X}What is Math.round(3.6)?

A

4.0

25
Q

Suppose s1 and s2 are two strings. What is the result of the following code?
s1.equals(s2) == s2.equals(s1)

A

true