Chapter 4 Flashcards
Which of the following statement prints smith\exam1\test.txt?
System.out.println(“smith\exam1\test.txt”);
Suppose x is a char variable with a value ‘b’. What is the output of the statement System.out.println(++x)?
c
To check whether a char variable ch is an uppercase letter, you write ___________.
(ch >= ‘A’ && ch <= ‘Z’)
[X]Which of the following is not a correct method in the Character class?
isLetterOrDigit(char) isLetter(char) toLowerCase(char) toUpperCase()
toLowerCase(char)
The statement System.out.printf(“%3.1f”, 1234.56) outputs ___________.
1234.6
The __________ method parses a string s to an int value.
Integer.parseInt(s); (Capital I in Integer)
The statement System.out.printf(“%5d”, 123456) outputs ___________.
123456
The statement System.out.printf(“%10s”, 123456) outputs ___________. (Note: * represents a space)
**123456
What is Math.rint(3.5)?
4.0
What is Math.rint(3.6)?
4.0
What is the return value of “SELECT”.substring(4, 4)?
An empty string
“abc”.compareTo(“aba”) returns ___________.
2
What is the return value of “SELECT”.substring(0, 5)?
“SELEC”
[X]Note that the Unicode for character A is 65. The expression “A” + 1 evaluates to ________.
Illegal expression
An int variable can hold __________.
120
Note that the Unicode for character A is 65. The expression ‘A’ + 1 evaluates to ________.
66
Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i?
System.out.println((char)i);
Which of the following assignment statements is correct? char c = 'd'; char c = '100'; char c = "d"; char c = "100";
char c = ‘d’;
Which of the following is the correct expression of character 4?
‘4’
Which of the following is the correct statement to return JAVA?
“Java”.toUpperCase()
A Java character is stored in __________.
2 bytes
The __________ method parses a string s to a double value.
Double.parseDouble(s);
[X}Will System.out.println((char)4) display 4?
no
[X}What is Math.round(3.6)?
4.0
Suppose s1 and s2 are two strings. What is the result of the following code?
s1.equals(s2) == s2.equals(s1)
true