Access Millions of academic & study documents

4 [18] What is the output from the following program Note if an

Content type
User Generated
Showing Page:
1/4
4. [18%] What is the output from the following program?
Note: if an exception is not handled, then the program is
terminated immediately.
class Test {
}
try {
f1(); }
} finally {
}
Output:
}
try {
f1(); }
} try {
f1(); }
} finally {
}
f1(); }
f2();
Solution
package javatest;
class JavaTest {
static void f1()
{

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
throw new RuntimeException(\"hello\");
}
static void f2()
{
try {
f1();
}
catch (Exception e)
{
System.out.println(\"FFF\");
} finally {
}
System.out.println(\"GGG\");
f1();
System.out.println(\"HHH\");
}
public static void main(String[] argv)
{
try {
f1();
}
catch (Exception e)
{
System.out.println(\"AAA\");

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now
Unformatted Attachment Preview
4. [18%] What is the output from the following program? Note: if an exception is not handled, then the program is terminated immediately. class Test { } try { f1(); } } finally { } Output: } try { f1(); } } try { f1(); } } finally { } f1(); } f2(); Solution package javatest; class JavaTest { static void f1() { throw new RuntimeException(\"hello\"); } static void f2() { try { f1(); } catch (Exception e) { System.out.println(\"FFF\"); } finally { } System.out.println(\"GGG\"); f1(); System.out.println(\"HHH\"); } public static void main(String[] argv) { try { f1(); } catch (Exception e) { System.out.println(\"AAA\"); } try { f1(); } catch (Exception e) { System.out.println(\"BBB\"); } finally { } System.out.println(\"DDD\"); f2(); System.out.println(\"EEE\"); f1(); // END class Test f2(); System.out.println(\"CCC\"); } } output AAA BBB DDD FFF GGG Name: Description: ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4