We have created a hierarchy of exceptions like below: A) The code written below throws an exception from the above hierarchy, depending on the value of c. Fill in the 5 gaps below, so that a correct working program is created. B) the following code throws two exceptions: Exception and ExceptionD. The exception name in the catch statement was removed as I expect you to recognize the order by which the exceptions are written in this code. B-1) what will be printed if the method is called by x = 0. B-2) what will be printed if the method is called by x = -1. B-3) what will be printed if the method is called by x = 1. C) A class called Exam is defined as below. Another class called TT2 extends class Exam and overrides all the three methods of Exam class. Specify what type of exceptions can be thrown by the methods that are defined in class TT2.
We have created a hierarchy of exceptions like below:
A) The code written below throws an exception from the above hierarchy, depending on the value of c.
Fill in the 5 gaps below, so that a correct working program is created.
B) the following code throws two exceptions: Exception and ExceptionD. The exception name in the catch statement was removed as I expect you to recognize the order by which the exceptions are written in this code.
B-1) what will be printed if the method is called by x = 0.
B-2) what will be printed if the method is called by x = -1.
B-3) what will be printed if the method is called by x = 1.
C) A class called Exam is defined as below.
Another class called TT2 extends class Exam and overrides all the three methods of Exam class. Specify what type of exceptions can be thrown by the methods that are defined in class TT2.
![B) the following code throws two exceptions: Exception and ExceptionD. The exception name in the catch statement was removed as I expect you to recognize the order by which the exceptions are written in this code.
public void fooMethod2(int x) {
try {
if (x == 0) throw new Exception();
else if (x < 0 ) throw new ExceptionD();
X = 10;
}
catch (
X = x + 1;
System.exit(0);
}
catch (
X = x + 100;
}
finally{
X = X + 2;
}
X = x + 3;
e) {
e ) {
System.out.println(x);
}
B-1) what will be printed if the method is called by x = 0.
B-2) what will be printed if the method is called by x = -1.
B-3) what will be printed if the method is called by x = 1.
C) A class called Exam is defined as below.
class Exam{
public void generateQuestion_1() throws Exceptionc {
// code was removed
}
public void generateQuestion_2() throws ExceptionD {
// code was removed
}
public void generateQuestion_3() throws Exception {
// code was removed
}
}
Another class called TT2 extends class Exam and overrides all the three methods of Exam class. Specify what type of exceptions can be thrown by the methods that are defined in class TT2.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F29176fe6-6fa3-4a86-8603-51952a73a9ea%2Fd88249ba-08dd-451d-8693-87a5aa43a728%2Fwv1nk8q_processed.png&w=3840&q=75)
![We have created a hierarchy of exceptions like below:
class ExceptionA extends Exception{
// code was removed
}
class ExceptionB extends ExceptionA{
// code was removed
}
class ExceptionC extends ExceptionA{
// code was removed
}
class ExceptionD extends ExceptionC{
// code was removed
A) The code written below throws an exception from the above hierarchy, depending on the value of c.
Fill in the 5 gaps below, so that a correct working program is created.
public void fooMethod (char c) {
try {
if (c ==' ') throw new Exception();
else if (c == 'a') throw new ExceptionD();
else if (c == 'b') throw new ExceptionC();
else if (c == 'c') throw new ExceptionA();
else if (c == 'd') throw new ExceptionB();
else c++;
}
catch (
System.out.println("A message related to this exception");
}
catch (
System.out.println("A message related to this exception");
}
catch (
System.out.println("A message related to this exception");
}
catch (
System.out.println("A message related to this exception");
}
catch (
System.out.println("A message related to this exception");
}
}
e) {
e) {
e) {
e) {
e ) {](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F29176fe6-6fa3-4a86-8603-51952a73a9ea%2Fd88249ba-08dd-451d-8693-87a5aa43a728%2Fsjc7tjc_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)