Programming > QUESTIONS & ANSWERS > Section 4 B. All the methods in the Math class are static methods. Quiz With Answers. (All)
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]
Last updated: 3 years ago
Preview 1 out of 6 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Buy NowInstant download
We Accept:
Can't find what you want? Try our AI powered Search
Connected school, study & course
About the document
Uploaded On
Oct 12, 2020
Number of pages
6
Written in
All
This document has been written for:
Uploaded
Oct 12, 2020
Downloads
0
Views
194
Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Scholarfriends · High quality services·