Preview:
import java.util.*;

public class MultipleExceptions {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        try{
            System.out.println("Enter marks separated by ,");
            String[] marks=sc.nextLine().split(",");
            int sum=findSum(marks);
          System.out.println("Sum: "+sum);
            System.out.println("Average marks:"+sum/marks.length);
        }
        catch(ArrayIndexOutOfBoundsException e){
            System.out.println(e);
        }catch(NumberFormatException e){
            System.out.println(e);
        }catch(Exception e){
            System.out.println(e);
        }finally{
            System.out.println("This is executed always");
        }
    }

    public static int findSum(String[] marks){
        int sum=0;
        //String[] marks;
        for(int i=0;i<marks.length;i++){
            sum+=Integer.parseInt(marks[i]);
        }
        return sum;
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter