Exceptions
- Which of these packages contain all the Java’s built in exceptions?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
java.util
- Which of these exceptions will be thrown if we use null reference for an arithmetic operation?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
If we use null reference anywhere in the code where the value stored in that reference is used then NullPointerException occurs.
- Which of these class is used to create user defined exception?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Exception class contains all the methods necessary for defining an exception. The class contains the Throwable class.
- What is the output of this program?
public class exception_Example
{
public static void main(String args[])
{
try
{
int array[] = {1, 2,3 , 4, 5};
for (int k = 0; k < 7; ++k)
System.out.print(array[k]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("5");
}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
When array index goes out of bound then ArrayIndexOutOfBoundsException exception is thrown by the system.
- Which of these classes is used to define exceptions?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Exception