Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

4/18/2018 Java Foundations - Teacher - English

Test: Section 4 Quiz 2 ­ L3­L5
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 4 Quiz 2 ­ L3­L5
(Answer all questions in this section)
1. The replaceFirst() method replaces only the first occurrence of matching character pattern in a string.  Mark for Review 
(1) Points  
True
False

2. The String concat() method concatenates only String data types.  Mark for Review 
(1) Points  
True
False

3. The indexOf() method returns the index value of a character in the string.  Mark for Review 
(1) Points  
True
False

4. What is the output?  Mark for Review 
   
public static void main(String args[]) { 
(1) Points  
   String greeting = "Java World!";  
 
   String w = greeting.replace("a", "A");
   System.out.println(w);  
}  

JAva World!
JavA World!
Java World!
JAvA World!

5. What is the output?  Mark for Review 
   
public static void main(String args[]) {
(1) Points  
 
   String alphaNumeric = "Java World!" + 8;
   System.out.println(alphaNumeric);  
}  

Compilation error.
Java World!8
Java World! + 8
Java World! 8

Page 1 of 3 Next Summary Finish Test

http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344
4/18/2018 Java Foundations - Teacher - English
Test: Section 4 Quiz 2 ­ L3­L5
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 4 Quiz 2 ­ L3­L5
(Answer all questions in this section)
6. The String class must be imported using java.lang.String;  Mark for Review 
(1) Points  
True
False

7. What is the output of the following code?  Mark for Review 
   
public static void main(String args[]) {
(1) Points  
   String firstString = "Java";  
 
   firstString = firstString.concat("World");
   System.out.println(firstString);  
}  

World
Java World
Java
JavaWorld

8. You need to generate random integer values in the range 2 through 10. This code fragment will produce the  Mark for Review 
desired result.  
  (1) Points
 
Random r = new Random();
r.nextInt(9) + 2;  

True
False

9. Which class is used to generate random numbers?  Mark for Review 
(1) Points  
Double
Number
Integer
Random

10. Which values are returned by the method nextBoolean();  Mark for Review 
(1) Points  
Returns the next value.
An integer value.
Nothing is returned.
Either a true or false.

Previous Page 2 of 3 Next Summary Finish Test

http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344
4/18/2018 Java Foundations - Teacher - English
Test: Section 4 Quiz 2 ­ L3­L5
Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which questions you need to answer
before submitting the test. Click Finish Test if you are ready to submit your test.
Section 4 Quiz 2 ­ L3­L5
(Answer all questions in this section)
11. Using the Random class requires an import statement.  Mark for Review 
(1) Points  
True
False

12. Which two are the features of the Math class?  Mark for Review 
(1) Points  
(Choose all correct answers)
You don’t have to worry about the data type returned from a Math method.
Common math functions like square root are taken care of in the language.
The Math methods can be invoked without creating an instance of a Math object.
Math methods can be invoked with Strings as arguments.

13. A constant field, like Math.PI is used to represent a fixed value.  Mark for Review 
(1) Points  
True
False

14. All the methods in the Math class are static methods.  Mark for Review 
(1) Points  
True
False

15. What is the package name which contains Math class?  Mark for Review 
(1) Points  
java.awt
java.lang
java.io
java.net

Previous Page 3 of 3 Summary Finish Test

http://ilearning.oracle.com/ilearn/en/learner/jsp/player.jsp?rco_id=2005667757&classroom_id=2035474607&scorm_attempt=1524034423157&sessionId=-192216619015240344

You might also like