Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 What class is at the top of the exception hierarchy? Question 2 What are the two direct subclasses of throwable? Question 3 What

Question 1

What class is at the top of the exception hierarchy?

Question 2

What are the two direct subclasses of throwable?

Question 3

What is wrong with this method declaration?

void methodB(){

throw new RuntimeException();

System.out.println("Exception thrown");

}

Question 4

What is wrong with the code fragment below? :

class MyClass { //....

}

//....

throw new MyClass();

Question 5

An inner catch can rethrow an exception to an outer catch

Question 6

We should typically catch Exceptions of type Error.

Question 7

Complete the following try catch block so that MyCustomException is caught and so does any

type of exceptions:

try{

//....

}

catch([a] ex1){

}

catch([b] ex2){

}

Question 8

Complete the class declaration of custom exception called MyCustomException. Also complete

declaration for the overloaded constructor so that it will accept a String parameter and pass it to

the base class constructor :

class [a] [b] {

public [c] ( [d] parameter){

[e] (parameter);

}

}

Question 9

What is wrong with this fragment?

//.....

vals[18] = 10;

catch (ArrayIndexOutOfBoundsException exc){

//handle error

}

Question 10

What is wrong with this code fragment?

class A extends Exception {}

class B extends A {}

//....

try{ //...

}

catch (A exc ) { .... }

catch (B exc) {.... }

Question 11

What happens if an exception is not caught? Choose the answers for this question:

Question 12

What is wrong with this method declaration?

void methodA(){

throw new ClassNotFoundException();

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions