Jumat, 14 Juli 2017

OJP QUIZ SECTION

1.  Which of the following correctly defines a StringBuilder?  Mark for Review
(1) Points
   
 
 A class that represents a string-like object. (*)
 
 A method that adds characters to a string.
 
 There is no such thing as a StringBuilder in Java.
 
 A class inside the java.util.regex package.
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 1.
   
  2.  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. (*)
 
 Parse the String. (*)
 
 Read the String backwards (from last element to first element). (*)
 
 You don't use a FOR loop with Strings
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 1.
   
  3.  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
   
 
 91204
 
 Compile fails.
 
 91227
 
 9120423 (*)
 
 23
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 1.
   
  4.  Which of the following correctly initializes a StringBuilder?  Mark for Review
(1) Points
   
 
 StringBuilder sb = "This is my String Builder";
 
 StringBuilder sb = StringBuilder(500);
 
 StringBuilder sb = new StringBuilder(); (*)
 
 None of the above.
   
  
Correct  Correct
   
  5.  Which of the following correctly defines Matcher?  Mark for Review
(1) Points
   
 
 A class in the java.util.regex package that stores the matches between a pattern and a string. (*)
 
 A regular expression symbol that represents any character.
 
 A class in the java.util.regex package that stores the format of a regular expression.
 
 A method of dividing a string into a set of sub-strings.
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 2.
6.  The following code correctly initializes a pattern with the regular expression "[0-9]{2}/[0-9]{2}/[0-9]{2}".
Pattern dateP = Pattern.compile("[0-9]{2}/[0-9]{2}/[0-9]{2}");
True or false?  Mark for Review
(1) Points
   
 
 True (*)
 
 False
   
  
Correct  Correct
   
  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?(Choose Two)  Mark for Review
(1) Points
   
   (Choose all correct answers)
   
 
 return str.contains(".");
 
 return str.matches(".?"); (*)
 
 if( str.length() == 0 || str.length() == 1)
{ return true;}
return false; (*)
 
 return str.matches("[a-z]*");
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 2.
   
  8.  Which of the following correctly defines Pattern?  Mark for Review
(1) Points
   
 
 A method of dividing a string into a set of sub-strings.
 
 A regular expression symbol that represents any character.
 
 A class in the java.util.regex package that stores matches.
 
 A class in the java.util.regex package that stores the format of a regular expression. (*)
   
  
Correct  Correct
   
  9.  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 (*)
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 2.
   
  10.  What is the correct explanation of when this code will return true?
return str.matches(".*[0-9]{6}.*");  Mark for Review
(1) Points
   
 
 Any time that str contains two dots.
 
 Any time that str contains a sequence of 6 digits. (*)
 
 Any time that str has between zero and nine characters followed by a 6.
 
 Any time str contains a 6.
 
 Always.
11.  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.
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 2.
   
  12.  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.
   
  13.  A base case can handle nested conditions.
True or false?  Mark for Review
(1) Points
   
 
 True (*)
 
 False
   
  
Correct  Correct
   
  14.  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.
   
  15.  Which two statements can create an instance of an array? (Choose Two)  Mark for Review
(1) Points
   
   (Choose all correct answers)
   
 
 Object oa = new double[5]; (*)
 
 char[] ca = "java";
 
 int[] ia = new int [5]; (*)
 
 int ia[][] = (1,2,3) (4,5,6);
 
 double da = new double [5];
   
  
Incorrect  Incorrect. Refer to Section 3 Lesson 3.

Tidak ada komentar:

Posting Komentar