void foo () {  try {  throw new Exception1 ();  print (" A ");  throw new Exception2 ();  print (" B ");  }  catch ( Exception1 e1 ) {  print " handler1 ";  }  print (" C ");  throw new Exception2 ();  }  void main () {  try {  try {  foo ();  print (" D ");  }  catch ( Exception1 e1 ) { print " handler2 "; }  print (" E ");  }  catch ( Exception2 e2 ) { print " handler3 "; }  } Write down the output of the program and justify why it is the output. Instead of the “replacement” semantics of exception handling used in modern languages, a very early design of exception handling introduced in the PL/I language uses a “binding” semantics. In particular, the design dynamically tracks a sequence of “catch” blocks that are currently active; a catch block is active whenever the corresponding try block is active. What will be the output of the following program if the language uses the “binding” semantics? Give the reasoning for your answer.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

void foo () {

 try {

 throw new Exception1 ();

 print (" A ");

 throw new Exception2 ();

 print (" B ");

 }

 catch ( Exception1 e1 ) {

 print " handler1 ";

 }

 print (" C ");

 throw new Exception2 ();

 }

 void main () {

 try {

 try {

 foo ();

 print (" D ");

 }

 catch ( Exception1 e1 ) { print " handler2 "; }

 print (" E ");

 }

 catch ( Exception2 e2 ) { print " handler3 "; }

 }

Write down the output of the program and justify why it is the output. Instead of the “replacement” semantics of exception handling used in modern languages, a very early design of exception handling introduced in the PL/I language uses a “binding” semantics. In particular, the design dynamically tracks a

sequence of “catch” blocks that are currently active; a catch block is active whenever the corresponding try block is active. What will be the output of the following program if the language uses the “binding” semantics? Give the reasoning for your answer.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,