Beruflich Dokumente
Kultur Dokumente
int i[1];
int[5] id={1,2,3,4,5};
12. When you instantiate a subclass, the superclass constructor will be also
invoked. True or False? Mark for Review
(1) Points
True (*)
False
5 (*)
Correct
&& (*)
! (*)
>
Correct
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Quiz
(Answer all questions in this section)
I only
II only
None of these
Correct
7. Examine the following code snippet. What is this an example of?
Mark for Review
public class Car extends Vehicle {
(1) Points
public Car() {
...
}
}
Encapsulation
Polymorphism
Inheritance (*)
Comments
public Student(){
studentId++;
}
public static int getStudentId(){
return studentId;
}
}
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1 Quiz
(Answer all questions in this section)
Correct
2. Arrays have built-in operations including add, clear, contains, get and remove. True
or false? Mark for Review
(0) Points
True
False (*)
Correct
In an Array you need to know the length and the current number of elements
stored.
An ArrayList can store multiple object types.
Correct
Nex Summa
Page 1 of 3
t ry
Test: Section 2 Quiz 1 - L1-L3
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
True (*)
False
Correct
4.class Node { }
ArrayList<?>
ArrayList<? super Animal>
ArrayList<T>
Correct
2 (*)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
True (*)
False
True (*)
False
Correct
True (*)
False
Correct
True (*)
False
Review your answers, feedback, and question scores below. An asterisk (*) indicates a
correct answer.
True
False (*)
Correct
True
False (*)
Correct
True
False (*)
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
{1, 1, 2, 22, 305, 26} because a set may contain duplicates and all its
elements are of the same type.
{"Apple", 1, "Carrot", 2} because it records the index of the elements with
following integers.
{1, 2, 5, 178, 259} because it contains no duplicates and all its elements are
of the same type. (*)
All of the above are sets because they are collections that can be made to fit
any of the choices.
Correct
vegetables.add("Cabbage"); (*)
vegetables += "Cabbage";
vegetables.get("Cabbage");
vegetables[0] = "Cabbage";
Correct
3. What is a set?
Mark for Review
(1) Points
Correct
4. ArrayList and Arrays both require you to define their size before use.
True or false? Mark for Review
(1) Points
True
False (*)
Correct
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
2. Identify the method, of those listed below, that is not available to both
StringBuilders and Strings? Mark for Review
(1) Points
length()
charAt(int index)
indexOf(String str)
Correct
Correct
Array
String (*)
StringBuilder
Parse
Correct
5. Matcher has a find method that checks if the specified pattern exists as a sub-string
of the string being matched. Mark for Review
True or false?
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
7. The following code correctly initializes a pattern with the regular expression "[0-
9]{2}/[0-9]{2}/[0-9]{2}". Mark for Review
(1) Points
Pattern dateP = Pattern.compile("[0-9]{2}/[0-9]{2}/[0-9]{2}");
True or false?
True (*)
False
Correct
8. What is the correct explanation of when this code will return true?
Mark for Review
return str.matches(".*[0-9]{6}.*");
(1) Points
Any time that str has between zero and nine characters followed by a 6.
Always.
9. Square brackets are a representation for any character in regular expressions "[
]". Mark for Review
True or false?
(1) Points
True
False (*)
Correct
10. Consider designing a program that organizes your contacts alphabetically by last
name, then by first name. Oddly, all of your contacts' first and last names are Mark for Review
exactly five letters long.
(1) Points
Which of the following segments of code establishes a Pattern namePattern with a
group for the first name and a group for the last name considering that the string
contactsName is always in the format lastName_firstName?
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
12. Which two statements can create an instance of an array? (Choose Two)
Mark for Review
(1) Points
char[] ca = "java";
True (*)
False
Correct
14. A non-linear recursive method is less expensive than a linear recursive method.
True or false? Mark for Review
(1) Points
True
False (*)
Correct
15. Consider the following recursive method recur(x, y). What is the value of recur(4,
3)? Mark for Review
(1) Points
public static int recur(int x, int y) {
if (x == 0) {
return y;
}
return recur(x - 1, x + y);
}
13 (*)
10
12
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 - Quiz 2 L4-L6
(Answer all questions in this section)
1. The Files class provides a instance method that creates a new BufferedReader.
True or false? Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
3. The Paths class provides a static get() method to find a valid Path.
True or false? Mark for Review
(1) Points
True (*)
False
Correct
5. Which statements are true when you compile and run this code.(Choose Two)
Mark for Review
1. public class Test{
(1) Points
2. public static String sayHello(String name) throws Exception{
3. if(name == null) throw new Exception();
4. return "Hello " + name;
5. }
6. public static void main(String[] args){
7. sayHello("Java");
8. }
9. }
The class Test compiles if line 6 contains a throws statement. public static
void main(String[] args) throws Exception{ (*)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Correct
True
False (*)
Correct
True (*)
False
Correct
9. Which three types of objects can be thrown using a throw statement? (Choose
Three) Mark for Review
(1) Points
Throwable (*)
Error (*)
Event
Exception (*)
Object
Bugs in code that make your program run different than expected (*)
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 3 - Quiz 2 L4-L6
(Answer all questions in this section)
11. What is the result from creating the following try-catch block?
Mark for Review
1.try {
(1) Points
2.} catch (Exception e) {
4.}
12. The Files class can perform which of the following functions?
Mark for Review
(1) Points
Correct
13. The new Paths class lets you resolve .. (double dot) path notation.
True or false? Mark for Review
(1) Points
True (*)
False
Correct
/home/user/username
\Users\UserName\data
data
Correct
True
False (*)
Correct