Halaman

Tuesday, July 21, 2020

Section 4 Quiz Java Programming 2019 Learner - English

Section 4
(Answer all questions in this section)

Square brackets are a representation for any character in regular expressions "[ ]".
True or false?


True


False (*)



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)

(Choose all correct answers)


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


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


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


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



Which of the following does not correctly match the regular expression symbol to its proper function?


"{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.


None of the above.



What does the dot (.) represent in regular expressions?


An indication for one or more occurrences of the preceding character.


A match for any character. (*)


A range specified between brackets that allows variability of a character.


Nothing, it is merely a dot.



What is the function of the asterisk (*) in regular expressions?


Indicates that the preceding character may occur 1 or more times in a proper match.


Indicates that the preceding character may occur 0 or 1 times in a proper match.


Indicates that the preceding character may occur 0 or more times in a proper match. (*)


The asterisk has no function in regular expressions.


Forward thinking helps when creating linear recursive methods.
True or false?


True


False (*)



Which case handles the last recursive call?


The recursive case


The convergence case


The base case (*)


The secondary case


The primary case



Which case does a recursive method call last?


Recursive Case


Convergence Case


Basic Case


Base Case (*)


None of the above



A non-linear recursive method is less expensive than a linear recursive method.
True or false?


True


False (*)



The base case condition can work with a constant or variable.
True or false?


True (*)


False


Which of the following methods can be used to replace a segment in a string with a new string?


remove(String oldString, String newString)


replaceAll(String oldString, String newString) (*)


replaceAll(String newString)


substring(int start, int end, String newString)


None of the above. There is no replaceAll(String newString) method with one argument.



Which of the following are true about parsing a String?(Choose Three)

(Choose all correct answers)


It is possible to use a for loop to parse a string. (*)


It is not possible to parse a string using regular expressions.


It is a way of dividing a string into a set of sub-strings. (*)


It is possible to use the String.split() method to parse a string. (*)



What class is the split() method a member of?


Array


Parse


String (*)


StringBuilder



Which of the following correctly defines a StringBuilder?


There is no such thing as a StringBuilder in Java.


A method that adds characters to a string.


A class inside the java.util.regex package.


A class that represents a string-like object. (*)



Which of the following methods are StringBuilder methods?


append


delete


insert


replace


All of the above. (*)


None of the above.

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam