5.7) What happens if a finally block modifies the value returned from a catch block?

public class MultipleReturn {
	int getInt() {
		int returnVal = 10;
		try {
			String[] students = { "Harry", "Paul" };
			System.out.println(students[5]);
		} catch (Exception e) {
			System.out.println("About to return :" + returnVal);
			return returnVal;
		} finally {
			returnVal = returnVal + 10;
			System.out.println("Return value is now :" + returnVal);
		}
		return returnVal;
	}
}

Problem 1: (Explain the output)

Output:

Problem 2: (Explain the output)

Output:

Problem 3:

Last updated

Was this helpful?