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