Java byzero Exception in java

enter image description here

to solve this problem I tried like below codes. And I don’t no I did it properly, but at least, I thought this code should work with no error. However as always error comes, the error in this time is by zero exception.

import java.io.FileInputStream;

import java.util.Scanner;


class Solution {
static int Answer;

static int factorial(int a){
    int result = 1;
    if(a<=1){
        return a;
    } else {
        for (int i = 1; i <= a; i++) {
            result = result*i;

        }
        return result;
    }
}



static int combination(int n, int r){

    if (r==0 || n==r){
        return 1;
    }
    else {
        return factorial(n)/(factorial(r)*factorial(n-r));
    }

} 



public static void main(String args[]) throws Exception {

    Scanner sc = new Scanner(System.in);

    int T = sc.nextInt();
    for(int test_case = 0; test_case < T; test_case++) {

         Answer = 0;
        /////////////////////////////////////////////////////////////////////////////////////////////


         int x = sc.nextInt();
         int y = sc.nextInt();

         for (int i = 0; i <= x; i++) {
            for (int j = 0; j <= y; j++) {
                Answer += combination(i+j,i);
            } 

        }

        /////////////////////////////////////////////////////////////////////////////////////////////
        System.out.println("Case #"+(test_case+1));
        System.out.println(Answer);
        }
    }
}

I have no idea why this code occurs by zero Exception
I thought I already handled it in static int combination(int n, int r){}.

    int T = sc.nextInt();
    for(int test_case = 0; test_case < T; test_case++) {

         Answer = 0;
        /////////////////////////////////////////////////////////////////////////////////////////////


         int x = sc.nextInt();
         int y = sc.nextInt();

         for (int i = 0; i <= x; i++) {
            for (int j = 0; j <= y; j++) {
                try { 
                    if(combination(i+j,i)==Double.POSITIVE_INFINITY)
                        throw new Exception();
                 Answer += combination(i+j,i);
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            } 

        }

        /////////////////////////////////////////////////////////////////////////////////////////////

        System.out.println("Case #"+(test_case+1));
        System.out.println(Answer);
}

And to handle this problem, I also tried try_catch like this, however it takes so long time, cannot solve it in 2 seconds.
Can you help me to solve this problem please?