Ch. 4 Quiz
Which of the following is the correct statement to return JAVA? - toUpperCase("Java") - "Java".toUpperCase("Java") - "Java".toUpperCase() - String.toUpperCase("Java")
"Java".toUpperCase()
What is the return value of "SELECT".substring(0, 5)? - "SELECT" - "SELEC" - "SELE" - "ELECT"
"SELEC"
Which of the following is the correct expression of character 4? - 4 - "4" - '\0004' - '4'
'4'
To check whether a char variable ch is an uppercase letter, you write ___________. - (ch >= 'A' && ch >= 'Z') - (ch >= 'A' && ch <= 'Z') - (ch >= 'A' || ch <= 'Z') - ('A' <= ch <= 'Z')
(ch >= 'A' && ch <= 'Z')
The statement System.out.printf("%10s", 123456) outputs ___________. (Note: * represents a space) - 123456**** - 23456***** - 12345***** - ****123456
****123456
An int variable can hold __________. - 120L - 120 - 120.0 - "x" - "120"
120
The statement System.out.printf("%3.1f", 1234.56) outputs ___________. - 123.4 - 123.5 - 1234.5 - 1234.56 - 1234.6
1234.6
The statement System.out.printf("%5d", 123456) outputs ___________. - 12345 - 23456 - 123456 - 12345.6
123456
"abc".compareTo("aba") returns ___________. - 1 - 2 - -1 - -2 - 0
2
What is the output of System.out.println('z' - 'a')? - 25 - 26 - a - z
25
What is Math.round(3.6)? - 3.0 - 3 - 4 - 4.0
4
- What is Math.ceil(3.6)? - 3.0 - 3 - 4.0 - 5.0
4.0
What is Math.rint(3.5)? - 3.0 - 3 - 4 - 4.0 - 5.0
4.0
What is Math.rint(3.6)? - 3.0 - 3 - 4.0 - 5.0
4.0
Note that the Unicode for character A is 65. The expression 'A' + 1 evaluates to ________. - 66 - B - A1 - Illegal expression
66
The Unicode of 'a' is 97. What is the Unicode for 'c'? - 96 - 97 - 98 - 99
99
The __________ method parses a string s to a double value. - double.parseDouble(s); - Double.parsedouble(s); - double.parse(s); - Double.parseDouble(s);
Double.parseDouble(s);
The __________ method parses a string s to an int value. - integer.parseInt(s); - Integer.parseInt(s); - integer.parseInteger(s); - Integer.parseInteger(s);
Integer.parseInt(s);
The expression "Java " + 1 + 2 + 3 evaluates to ________. - Java123 - Java6 - Java 123 - java 123 - Illegal expression
Java 123
Will System.out.println((char)4) display 4? - Yes - No
No
Which of the following statement prints smith\exam1\test.txt? - System.out.println("smith\exam1\test.txt"); - System.out.println("smith\\exam1\\test.txt"); - System.out.println("smith\"exam1\"test.txt"); - System.out.println("smith"\exam1"\test.txt");
System.out.println("smith\\exam1\\test.txt");
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(i); - System.out.println((char)i); - System.out.println((int)i); - System.out.println(i + " ");
System.out.println((char)i);
What is the return value of "SELECT".substring(4, 4)? - an empty string - C - T - E
an empty string
Which of the following assignment statements is correct? - char c = 'd'; - char c = '100'; - char c = "d"; - char c = "100";
char c = 'd';
A Java character is stored in __________. - one byte - two bytes - three bytes - four bytes
two bytes