1.
All the methods in the Math class are static methods.
Mark for Review
(1) Points
True (*)
False
...
1.
All the methods in the Math class are static methods.
Mark for Review
(1) Points
True (*)
False
2.
What is the approximate value of PI? Mark for Review
(1) Points
0
2.718
The value varies.
3.141 (*)
3.
A constant field, like Math.PI is used to represent a fixed value. Mark for Review
(1) Points
True (*)
False
4.
Every method of the Math class returns a numerical result. Mark for Review
(1) Points
True (*)
False
In. Refer to Section 4 Lesson 5.
5.
What is the output?
public static void main(String args[]) {
String greeting = "Java World!";
String w = greeting.substring(7, 11);
System.out.println(w);
} Mark for Review
(1) Points
ld!
orld!
rld
rld! (*)
6.
A String is a sequence characters. Mark for Review
(1) Points
True (*)
False
7.
The replaceFirst() method replaces only the first occurrence of matching character pattern in a string. Mark for Review
(1) Points
True (*)
False
8.
String objects are immutable. Mark for Review
(1) Points
True (*)
False
9.
The String class must be imported using java.lang.String; Mark for Review
(1) Points
True
False (*)
10.
Which method returns the length of a String? Mark for Review
(1) Points
compareTo()
findLength ()
length() (*)
charAt()
11.
What is the output?
public static void main(String args[]) {
String alphaNumeric = "Java World!" + 8;
System.out.println(alphaNumeric);
} Mark for Review
(1) Points
Compilation error.
Java World!8 (*)
Java World! 8
Java World! + 8
12.
Using the Random class requires an import statement. Mark for Review
(1) Points
True (*)
False
13.
You need to generate random integer values between 0 and 80 (inclusive). Which statement should you use? Mark for Review
(1) Points
nextInt(80);
nextInt();
nextInt(0-79);
nextInt(81); (*)
14.
You need to generate random integer values in the range 2 through 10. This code fragment will produce the desired result.
Random r = new Random();
r.nextInt(9) + 2; Mark for Review
(1) Points
True (*)
False
15.
Which values are returned by the method nextBoolean(); Mark for Review
(1) Points
Returns the next value.
Either a true or false. (*)
An integer value.
Nothing is returned.
[Show More]