Trivia question – “Finally”

Here is a confusing question – what does the next code prints?

	public static void doStam() {
		try {
			doExcption();
			return;
		}
		finally {
			System.out.println("Finally");
		}
	}
	
	public static void main(String[] args) {
		doStam();
	}
	
	public static void doExcption() {
		String [] stam = new String[0];
		//purpose exception
		stam[1].toString();
	}




Answer:
Finally
Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: …

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>