import java.lang.IndexOutOfBoundsException;
import java.lang.NullPointerException;

class Oct4 {
	public static void main(String[] args) {

		
		//

		block();		// calling the method
		

		int val = block2();	
		// val holds 5
		
		int val2 = block3(7);
		// val2 holds 8

		int[] arr = {1,3,5,7,9};  // hard code list of array elements

		int firstElm = 0;

		try {
			firstElm = elementAt(null, 7);
		}
		catch(NullPointerException e) {
			System.out.println("Exception caught: " + e);
		}
		catch(IndexOutOfBoundsException e) {
			System.out.println("Exception caught: " + e);
		}

		System.out.println("Finishing the program...");
		


	}

	static void block() {

	}

	static int block2() {
		return 5;
	}

	static int block3(int input) {
		return (input + 1);
	}

	static int elementAt(int[] arr, int index) {

		if(arr == null) {
			throw new NullPointerException();	
		}
	
		if (index < 0 || index >= arr.length) {
			throw new IndexOutOfBoundsException();	
		}

		// return element at specified index in arr

		return arr[index];
	}



}
