# D4 - M

## Unlock all answers in this set

question
What is Math.round(3.6)? a. 3.0 b. 3 c. 4 d. 4.0
c
question
What is Math.rint(3.6)? a. 3.0 b. 3 c. 4.0 d. 5.0
c
question
What is Math.rint(3.5)? a. 3.0 b. 3 c. 4 d. 4.0 e. 5.0
d
question
What is Math.ceil(3.6)? a. 3.0 b. 3 c. 4.0 d. 5.0
c
question
What is Math.floor(3.6)? a. 3.0 b. 3 c. 4 d. 5.0
a
question
To obtain the sine of 35 degrees, use _______. a. Math.sin(35) b. Math.sin(Math.toRadians(35)) c. Math.sin(Math.toDegrees(35)) d. Math.sin(Math.toRadian(35)) e. Math.sin(Math.toDegree(35))
b
question
To obtain the arc sine of 0.5, use _______. a. Math.asin(0.5) b. Math.asin(Math.toDegrees(0.5)) c. Math.sin(Math.toRadian(0.5)) e. Math.sin(0.5)
a
question
Math.asin(0.5) returns _______. a. 30 b. Math.toRadians(30) c. Math.PI / 4 e. Math.PI / 2
b
question
Math.sin(Math.PI) returns _______. a. 0.0 b. 1.0 c. 0.5 e. 0.4
a
question
Math.cos(Math.PI) returns _______. a. 0.0 b. 1.0 c. -1.0 e. 0.5
c
question
Which of the following is the correct expression of character 4? a. 4 b. "4" c. ' 004' d. '4'
d
question
A Java character is stored in __________. a. one byte b. two bytes c. three bytes d. four bytes
b
question
Suppose x is a char variable with a value 'b'. What is the printout of the statement System.out.println(++x)? a. a b. b c. c d. d
c
question
Which of the following statement prints smithexam1test.txt? a. System.out.println("smithexam1test.txt"); b. System.out.println("smithexam1test.txt"); c. System.out.println("smith"exam1"test.txt"); d. System.out.println("smith"exam1"test.txt");
b
question
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(i); b. System.out.println((char)i); c. System.out.println((int)i); d. System.out.println(i + " ");
b
question
The Unicode of 'a' is 97. What is the Unicode for 'c'? a. 96 b. 97 c. 98 d. 99
d
question
Will System.out.println((char)4) display 4? a. Yes b. No
b
question
What is the printout of System.out.println('z' - 'a')? a. 25 b. 26 c. a d. z
a
question
An int variable can hold __________. a. 'x' b. 120f c. 120.0 d. "x" e. "120"
a
question
Which of the following assignment statements is correct? a. char c = 'd'; b. char c = 1000001; c. char c = "d"; d. char c = "100";
a
question
'3' - '2' + 'm' / 'n' is ______. a. 0 b. 1 c. 2 d. 3
b
question
To check whether a char variable ch is an uppercase letter, you write ___________. a. (ch >= 'A' && ch >= 'Z') b. (ch >= 'A' && ch <= 'Z') c. (ch >= 'A' || ch <= 'Z') d. ('A' <= ch <= 'Z')
b
question
Which of following is not a correct method in Character? a. isLetterOrDigit(char) b. isLetter(char) c. isDigit() d. toLowerCase(char)
c
question
Suppose Character x = new Character('a'), __________________ returns true. a. x.equals(new Character('a')) b. x.compareToIgnoreCase('A') c. x.equalsIgnoreCase('A') d. x.equals(65) e. x.equals("a") f. A & D
F
question
Suppose s is a string with the value "java". What will be assigned to x if you execute the following code? char x = s.charAt(4); a. 'a' b. 'v' c. Nothing will be assigned to x, because the execution causes the runtime error StringIndexOutofBoundsException.
c
question
Suppose s1 and s2 are two strings. Which of the following statements or expressions is incorrect? a. String s3 = s1 - s2; b. boolean b = s1.compareTo(s2); c. char c = s1; d. char c = s1.charAt(s1.length()); e. All the above
e
question
Suppose s1 and s2 are two strings. What is the result of the following code? s1.equals(s2) == s2.equals(s1) a. true b. false
a
question
"abc".compareTo("aba") returns ___________. a. 1 b. 2 c. -1 d. -2 e. 0
b
question
"AbA".compareToIgnoreCase("abC") returns ___________. a. 1 b. 2 c. -1 d. -2 e. 0
d
question
What is the return value of "SELECT".substring(0, 5)? a. "SELECT" b. "SELEC" c. "SELE" d. "ELECT"
b
question
What is the return value of "SELECT".substring(4, 4)? a. an empty string b. C c. T d. E
a
question
To check if a string s contains the prefix "Java", you may write a. if (s.startsWith("Java")) ... b. if (s.indexOf("Java") == 0) ... c. if (s.substring(0, 4).equals("Java")) ... d. if (s.charAt(0) == 'J' && s.charAt(1) == 'a' && s.charAt(2) == 'v' && s.charAt(3) == 'a') ... e. All the above
e
question
Which of the following is the correct statement to return JAVA? a. toUpperCase("Java") b. "Java".toUpperCase("Java") c. "Java".toUpperCase() d. String.toUpperCase("Java")
c
question
The expression "Java " + 1 + 2 + 3 evaluates to ________. a. Java123 b. Java6 c. Java 123 d. java 123 e. Illegal expression
c
question
Note that the Unicode for character A is 65. The expression "A" + 1 evaluates to ________. a. 66 b. B c. A1 d. Illegal expression
c
question
Note that the Unicode for character A is 65. The expression 'A' + 1 evaluates to ________. a. 66 b. B c. A1 d. Illegal expression
a
question
The __________ method parses a string s to an int value. a. integer.parseInt(s); b. Integer.parseInt(s); c. integer.parseInteger(s); d. Integer.parseInteger(s);
b
question
The __________ method parses a string s to a double value. a. double.parseDouble(s); b. Double.parsedouble(s); c. double.parse(s); d. Double.parseDouble(s);
d
question
Analyze the following code: int i = 3434; double d = 3434; System.out.printf("%5.1f %5.1f", i, d); a. The code compiles and runs fine to display 3434.0 3434.0. b. The code compiles and runs fine to display 3434 3434.0. c. i is an integer, but the format specifier %5.1f specifies a format for double value. The code has an error.
c
question
You can cast a character value to an int, or an int to char. a. true b. false
a
question
Is 'a' larger than 'A'? a. Yes b. No
a
question
You can assign the value in ________ to an int variable. a. 'x' b. 93444444 c. 98.3 d. true
a
question
Which of the following is the correct expression of character a? a. 'a' b. "a" c. ' 00a' d. 'a'
a
question
Which of the following assignment statements is correct to assign character 5 to c? a. char c = '5'; b. char c = 5; c. char c = "5"; d. char c = "344";
a
question
The expression 'c' - 'e' is ________________. a. 2 b. -2 c. a random number d. invalid
b
question
What is "Welcome" + 1 + 1*2? a. Welcome11*2 b. Welcome4 c. Welcome12 d. Welcome3
c
question
parseInt is a method in the _______ class. a. Integer b. Double c. Math d. System
a
question
parseDouble is a method in the _______ class. a. Integer b. Double c. Math d. System
b
question
To concatenate s1, s2, s3, and s4, you write ______________. a. s1.concate(s2).concate(s3).concate(s4); b. s1.concate(s2) + s3.concate(s4); c. ((s1.concate(s2)).concate(s3)).concate(s4); d. s1.concate(s2).(concate(s3).concate(s4)); e. A,B & C
e
question
"unhappy".substring(2) returns "happy". a. true b. false
a
question
"smiles".substring(1, 5) returns "mile". a. true b. false
a
question
You compare two strings s1 and s2 using ________. a. compare(s1, s2) b. s1.compare(s2) c. compareTo(s1, s2) d. s1.compareTo(s2)
d
question
"ab".compareTo("aB") is _________. a. greater than 0 b. less than 0 c. equal to 0 d. less than or equal to 0
a
question
Which of the following statements are correct to concatenate string s1 into s2. a. s1 += s2; b. s2 += s1; c. s2.concate(s1); d. s1.concate(s2); e. B & C
e
question
Which of the following statements are incorrect? a. float f = 4.5; b. char c = "r"; c. String s = 'r'; d. int k = null; e. All the above.
e
question
"abcdefgh".subString(1, 3) returns ________. a. abc b. bcd c. bc d. cde
c
question
Assume that the ASCII code for character c is 99. What is the printout of the following code? System.out.println("a" + 'c'); a. a99 b. ac c. 9799 d. 196
b
question
Assume that the ASCII code for character c is 99 and for a is 97. What is the printout of the following code? System.out.println('a' + 'c'); a. a99 b. ac c. 9799 d. 196
d
question
Assume that the ASCII code for character c is 99 and for a is 97. What is the printout of the following code? System.out.println("AB" + 'a' + 'c'); a. ABac b. AB9799 c. ABa99 d. AB196
a
question
Which of the following is a possible output for (int)(51 * Math.random())? a. 0 b. 50 c. 100 d. 500 e. A & B
e
question
Which of the following method results in 8.0? a. Math.round(8.5) b. Math.rint(8.5) c. Math.ceil(8.5) d. Math.floor(7.5)
b
question
Which of the following method returns the sine of 90 degree? a. Math.sine(90) b. Math.sin(90) c. Math.sin(PI) d. Math.sin(Math.toRadian(90)) e. Math.sin(Math.PI)
d
question
Math.pow(3, 3) returns _______. a. 27 b. 9 c. 27.0 d. 9.0
c
question
Math.sqrt(4) returns _______. a. 2 b. 2.0 c. 1 d. 1.0