Senin, 08 Mei 2017

QUIZ 3 OJP

  Which case does a recursive method call last? Mark for Review
(1) Points


Recursive Case


Convergence Case


Basic Case


Base Case (*)


None of the above



Incorrect Incorrect. Refer to Section 3 Lesson 3.


2. Forward thinking helps when creating linear recursive methods.
True or false? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 3 Lesson 3.


3. A linear recursive method can call how many copies of itself? Mark for Review
(1) Points


1 (*)


2 or more


None



Incorrect Incorrect. Refer to Section 3 Lesson 3.


4. Consider the following recursive method recur(x, y). What is the value of recur(4, 3)?

    public static int recur(int x, int y) {
        if (x == 0) {
            return y;
        }
        return recur(x - 1, x + y);
    } Mark for Review
(1) Points


12


10


9


13 (*)



Incorrect Incorrect. Refer to Section 3 Lesson 3.


5. Identify the method, of those listed below, that is not available to both StringBuilders and Strings? Mark for Review
(1) Points


indexOf(String str)


charAt(int index)


delete(int start, int end) (*)


length()
What class is the split() method a member of? Mark for Review
(1) Points


String (*)


Parse


StringBuilder


Array



Incorrect Incorrect. Refer to Section 3 Lesson 1.


7. Using the FOR loop method of incrementing through a String is beneficial if you desire to: (Choose Three) Mark for Review
(1) Points

(Choose all correct answers)


Search for a specific character or String inside of the String. (*)


Read the String backwards (from last element to first element). (*)


Parse the String. (*)


You don't use a FOR loop with Strings



Incorrect Incorrect. Refer to Section 3 Lesson 1.


8. What is the result from the following code?

public class Test {
    public static void main(String[] args) {
     String str = "91204";
     str += 23;
     System.out.print(str);
    }
} Mark for Review
(1) Points


9120423 (*)


23


Compile fails.


91227


91204



Incorrect Incorrect. Refer to Section 3 Lesson 1.


9. Which of the following does not correctly match the regular expression symbol to its proper function? Mark for Review
(1) Points


"{x}" means there must be x occurrences of the preceding character in the string to be a match.


"?" means there may be zero or one occurrences of the preceding character in the string to be a match.


"+" means there may be zero or more occurrences of the preceding character in the string to be a match. (*)


"{x,}" means there may be x or more occurrences of the preceeding character in the string to be a match.


"{x,y}" means there may be between x and y occurrences of the preceding character in the string to be a match.



Incorrect Incorrect. Refer to Section 3 Lesson 2.


10. Which of the following methods for the String class take a regular expression as a parameter and returns true if the string matches the expression? Mark for Review
(1) Points


matches(String regex) (*)


compareTo(String regex)


equalsIgnoreCase(String regex)


equals(String regex)



Incorrect Incorrect. Refer to Section 3 Lesson 2.
Consider that you are writing a program for analyzing feedback on the video game you have developed. You have completed everything except the segment of code that checks that the user's input, String userI, is a valid rating. Note that a valid rating is a single digit between 1 and 5 inclusive. Which of the following segments of code returns true if the user's input is a valid rating?(Choose Two) Mark for Review
(1) Points

(Choose all correct answers)


return userI.matches("{1-5}");


return userI.matches("[1-5]{1}"); (*)


return userI.matches("[1-5].*");


return userI.matches("[1-5]"); (*)



Incorrect Incorrect. Refer to Section 3 Lesson 2.


12. Which of the following correctly defines Pattern? Mark for Review
(1) Points


A regular expression symbol that represents any character.


A class in the java.util.regex package that stores matches.


A method of dividing a string into a set of sub-strings.


A class in the java.util.regex package that stores the format of a regular expression. (*)



Correct Correct


13. Which of the following correctly initializes a Matcher m for Pattern p and String str? Mark for Review
(1) Points


Matcher m = p.matcher(str); (*)


Matcher m = new Matcher(p,str);


Matcher m = str.matcher(p);


Matcher m = new Matcher();



Incorrect Incorrect. Refer to Section 3 Lesson 2.


14. Which of the following correctly defines a repetition operator? Mark for Review
(1) Points


A symbol that represents any character in regular expressions.


A method that returns the number of occurrences of the specified character.


symbol in regular expressions that indicates the number of occurrences a specified character appears in a matching string. (*)


None of the above.



Correct Correct


15. In a regular expression, {x} and {x,} represent the same thing, that the preceding character may occur x or more times to create a match.
True or false? Mark for Review
(1) Points


True


False (*)



Correct Correct

Tidak ada komentar:

Posting Komentar