100% found this document useful (1 vote)
1K views3 pages

JFo Section 8

The document discusses Java exception handling and debugging using the NetBeans IDE. It also covers array concepts like accessing elements, length property, and ArrayIndexOutOfBoundsException. Multiple choice questions are provided about these topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views3 pages

JFo Section 8

The document discusses Java exception handling and debugging using the NetBeans IDE. It also covers array concepts like accessing elements, length property, and ArrayIndexOutOfBoundsException. Multiple choice questions are provided about these topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

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
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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy