Inheritance in Java | Code

import java.util.Scanner;
class hi
{
public static class math
{
int n1,n2;
math()
{
Scanner a=new Scanner(System.in);
System.out.println("Enter 1st Value \n");
n1=a.nextInt();
System.out.println("Enter 2nd Value \n");
n2=a.nextInt();
}
};
public static class ans extends math
{
int sum()
{
return n1+n2;
}
};
public static void main(String []args)
{
ans myans = new ans();
System.out.println("Sum = "+myans.sum());
}

}