Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

15. A string is a sequence characters. True or False 7. Which two are the featur

ID: 3869443 • Letter: 1

Question

15. A string is a sequence characters.

True or False

7. Which two are the features of the Math dass? (Choose al correct answers) LJ Math methods can be invoked with Strings as arguments. Common math functions ike square root are taken care of in the language. Math methods can be invoked without creating an instance of a Math object You don't have to worry about the data type returned from a Math method. 8. Which is NOT true? Static methods can be invoked through the cdass name. OStatic methods must be of return void. O Static methods can be invoked through an instance of a dass OA dass can have multiple static methods 9. The replaceFirst0 method replaces only the first occurrence of matching character pattern in a string. True O False 10. The String dlass must be imported using java. lang.String True OFalse

Explanation / Answer

7. a) incorrect as math functions in Java takes argument only as double, float, int or long and not as string

   b)Correct, Java.lang.math class includes mathematical functions such as expoential, sqaure roots, logarithmic and trignometric functions.

   c) Correct, as math class is a part of java.lang so it is not to be imported separetly and if it is a static methods you need not to create a object of that class

d)Incorrect, as math function return double value.

8. a) true, static methods can be called with class name and not with class instance

   b) False, static method cam return any value it is not restricted as void.

   c) True, If you are compiling a program containing static function and using a class instance to execute it you will get a warning but you can still execute a program.

d) True, we can have any number of static methods in our classes.

9) a) True, replaceFirst() replaces first occurence of matching substring in the string. Its syntax is string replaceFirst(string regularexpression, string replacementexpression).

Example: String str=("welcome to CHegg.COM");

str.replaceFirst("CHegg.COM","Chegg.com");

10) b) String class is in package java.lang so it need not to be explicitly imported in programs, as soon as you use java.lang it will be automatically imported.

11) java world!8 is the answer as + operator is concatenating "java world!" and numeric 8.

12) jAvA world! is the answer as replace function replaces all the occurences of "a" in the string with "A"

13) Javaworld! is the answer as concat function join both the strings without entering any space character

14) rld! is answer as substring is taken after 7th position to 11th character.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote