0% found this document useful (0 votes)
50 views

Java 8

The document discusses debugging Java programs using the NetBeans debugger, setting breakpoints, and handling exceptions. It also covers key aspects of arrays and ArrayLists in Java like accessing elements, traversing, and checking for out-of-bounds errors. Testing and debugging are important parts of the software development process.

Uploaded by

XIOMARA JIMÉNEZ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Java 8

The document discusses debugging Java programs using the NetBeans debugger, setting breakpoints, and handling exceptions. It also covers key aspects of arrays and ArrayLists in Java like accessing elements, traversing, and checking for out-of-bounds errors. Testing and debugging are important parts of the software development process.

Uploaded by

XIOMARA JIMÉNEZ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

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?

int[] array = {10, 20, 30};

int b = 0;

try{

System.out.println("1");

int c = (array[3] / b);

System.out.println("2");

catch(Exception ex){

System.out.println(ex.toString());

Mark for Review

(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

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

ArrayIndexOutOfBoundsException

10 (*)

Correct

You might also like