JFo Section 8
JFo Section 8
Using the NetBeans debugger, you can set breakpoints and trace through a program
one line at a time.
Mark for Review
(1) Points
True (*)
False
Correct
2. Runtime errors can be caught by Java’s exception handling mechanism.
Mark for Review
(1) Points
True (*)
False
Correct
3. Testing and debugging are important activities in software development.
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 8 Lesson 4.
4. An exception is an error that occurs during the execution of a program at run-
time that disrupts the normal flow of the Java program.
Mark for Review
(1) Points
True (*)
False
Correct
5. If the try block succeeds then no exception has occurred.
Mark for Review
(1) Points
True (*)
False
Correct
6. What is the danger of catching a generic Exception type as shown below?
(1) Points
The details of the Exception object ex are too general to be useful. (*)
An Exception will never occur.
An ArithmeticException cannot be caught.
An ArrayIndexOutOfBoundsException cannot be caught.
Correct
7. Which is not used to traverse an ArrayList?
Mark for Review
(1) Points
do- while loop (*)
iterator
ListIterator
for-each loop
Correct
8. Which is NOT a benefit of ArrayList class?
Mark for Review
(1) Points
You can use an ArrayList list to store Java primitive values (like int). (*)
An ArrayList grows as you add elements.
An ArrayList shrinks as you remove elements.
You can remove all of the elements of an ArrayList with a method.
Incorrect. Refer to Section 8 Lesson 2.
9. You can access elements in an ArrayList by their index.
Mark for Review
(1) Points
True (*)
False
Correct
10. What is the starting index of an array?
Mark for Review
(1) Points
1
0 (*)
It depends on the type of the array.
You can start with anything
Incorrect. Refer to Section 8 Lesson 1.
11. You can access the size of any array by using the array’s “length” property.
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 8 Lesson 1.
12. What is the output?
int[] arr = new int[2];
for(int i=0; i < arr.length; i++){
System.out.print("hai ");
}
Mark for Review
(1) Points
12
hai hai hai
hai
hai hai (*)
Correct
13. The Java compiler does not check for an ArrayIndexOutOfBoundsException during
the compilation of a program containing arrays.
Mark for Review
(1) Points
True (*)
False
Correct
14. Arrays are like variables which must be declared prior to use.
Mark for Review
(1) Points
True (*)
False
Correct
15. What is the output?
int[] arr = new int[1];
arr[0] = 10;
System.out.println(arr[0]);
Mark for Review
(1) Points
1
ArrayIndexOutOfBoundsException
0
10 (*)
Correct