Skip to main content

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

Comments

Popular posts from this blog

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) LAST_NAME  NOT NULL     VARCHAR2 (25) EMAIL NOT NULL     VARCHAR2 (25) PHONE_NUMBER                  VARCHAR2 (20) HIRE_DATE   NOT NULL     DATE JOB_ID           NOT NULL     VARCHAR2 (10) SALARY                     NUMBER (8,2) COMMISSION_PCT                NUMBER (2,2) MANAGER_ID                       NUMBER (6) DEPARTMENT_ID                 NUMBER (4) JOBS Table: Name   Null?    Type JOB_ID           NOT NULL     VARCHAR2 (10) JOB_TITLE     NOT NULL     VARCHAR2 (35) MIN_SALARY                      

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 FROM f_staffs WHERE salary IN (SELECT last_name, first_name FROM f_staffs WHERE salary <5000 o:p="">             SELECT last_name, first_name FROM f_staffs WHERE salary = (SELECT salary FROM f_staffs WHERE salary < 5000);             SELECT last_name, first_name FROM f_staffs WHERE salary IN (SELECT salary FROM f_staffs WHERE salary > 5000); (*)             SELEC

Section 2 Quiz Database Design Oracle

Section 2 Quiz             (Answer all questions in this section) 1.         An Entity Relationship model is independent of the hardware or software used for implementation. True or False?  Mark for Review (1) Points             True (*)             False 2.         A well structured ERD will show only some parts of the finished data model. You should never try to model the entire system in one diagram, no matter how small the diagram might be. True or False?           Mark for Review (1) Points             True             False (*) 3.         The purpose of an ERD is to document the proposed system and facilitate discussion and understanding of the requirements captured by the developer. True or False?          Mark for Review (1) Points             True (*)             False 4. Documenting Business Requirements helps developers control the scope of the system and prevents users from claiming that the new system does not meet their business req