0% found this document useful (0 votes)
0 views

exceptionHandlingEx(1) (1)

The Java application defines a class with a static string variable initialized to 'Hi'. It contains methods that manipulate the string based on exception handling, ultimately appending messages based on whether exceptions are thrown. The program demonstrates exception propagation and the use of finally blocks to ensure certain code executes regardless of exceptions.

Uploaded by

ghalaalsqoor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

exceptionHandlingEx(1) (1)

The Java application defines a class with a static string variable initialized to 'Hi'. It contains methods that manipulate the string based on exception handling, ultimately appending messages based on whether exceptions are thrown. The program demonstrates exception propagation and the use of finally blocks to ensure certain code executes regardless of exceptions.

Uploaded by

ghalaalsqoor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

public class JavaApplication135 {

static String str="Hi";

public static void main (String[] args) {

method1();

System.out.print(str);

public static void method1 () {

try{

method2();

} catch(Exception ex){

str+="\nGood Morning..";

public static void method2() throws Exception {

try{

method3();

str+="\nHello..";

//throw new Exception();

} catch(Exception ex){

throw new Exception();

// System.out.println("hi"); will cause a compilation error.

} finally{

str+="\nHave a nice day..";

method3();

str+="\nGood Bye..";

public static void method3 () throws Exception {

throw new Exception();

//System.out.println("A");

//throw new Exception();

//System.out.println("hi"); //will cause a compilation error.

}
} //System.out.println("A");

//str+="\n A";

You might also like