Langsung ke konten utama

Section 3 String processing Oracle Java Programming

Section 3 String processing
                (Answer all questions in this section)

1.            Which of the following are true about parsing a String?   Mark for Review
                                                (Choose all correct answers)      
                It is a way of dividing a string into a set of sub-strings. (*)
                It is not possible to parse a string using regular expressions.
                It is possible to use a for loop to parse a string. (*)
                It is possible to use the String.split() method to parse a string. (*)

2.            Which of the following correctly defines a StringBuilder?
                A method that adds characters to a string.
                A class inside the java.util.regex package.
                A class that represents a string-like object. (*)
                There is no such thing as a StringBuilder in Java.

3.            Identify the method, of those listed below, that is not available to both StringBuilders and Strings?            Mark for Review
                length()
                delete(int start, int end) (*)
                charAt(int index)
                indexOf(String str)

4.            A regular expression is a character or a sequence of characters that represent a string or multiple strings.
True or false?    Mark for Review
                True (*)
                False

5.            What does the dot (.) represent in regular expressions? Mark for Review
(1) Points
                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.

6.            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
                True
                False (*)

7.            Your teacher asks you to write a segment of code that returns true if String str contains zero or one character(s) and false otherwise. Which of the following code segments completes this task?       Mark for Review
                                                (Choose all correct answers)      
                return str.matches(".?"); (*)
                return str.contains(".");
                if( str.length() == 0 || str.length() == 1)
{ return true;}
return false; (*)
                return str.matches("[a-z]*");

8.            Which of the following correctly defines Pattern?             Mark for Review
                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. (*)

9.            Which of the following correctly initializes a Matcher m for Pattern p and String str?         Mark for Review
                Matcher m = p.matcher(str); (*)
                Matcher m = new Matcher(p,str);
                Matcher m = str.matcher(p);
                Matcher m = new Matcher();

10.          One benefit to using groups with regular expressions is that you can segment a matching string and recall the segments (or groups) later in your program.
True or false?    Mark for Review
                True (*)

                False

Komentar

Postingan populer dari blog ini

Section 6 Quiz Oracle Database Programming with SQL

Section 6 Quiz             (Answer all questions in this section)                                                             1.         Given the following descriptions of the employees and jobs tables, which of the following scripts will display each employee ï¾’ s possible minimum and maximum salaries based on their job title? EMPLOYEES Table: Name   Null?    Type EMPLOYEE_ID          NOT NULL     NUMBER (6) FIRST_NAME             VARCHAR2 (20) ...

Section 10 Quiz Database Programming With SQL

Section 10 Quiz             (Answer all questions in this section) 1.         A multiple-row operator expects how many values?   Mark for Review (1) Points             One or more (*)             Only one             Two or more             None 2.         The salary column of the f_staffs table contains the following values: 4000 5050 6000 11000 23000 Which of the following statements will return the last_name and first_name of those employees who earn more than 5000?  Mark for Review (1) Points             SELECT last_name, first_name ...

Section 6 Quiz Database Design Oracle

Section 6 Quiz             (Answer all questions in this section) 1.         Examine the following Entity and decide which rule of Normal Form is being violated: ENTITY: CLIENT ATTRIBUTES:     # CLIENT ID     FIRST NAME     LAST NAME     STREET     CITY     ZIP CODE  Mark for Review (1) Points             1st Normal Form.             2nd Normal Form.             3rd Normal Form.             None of the above, the entity is fully normalised. (*) 2.         A transitive dependency exists when any attribute in an entity...