class multiply
{
//instance variable
int num1;
int num2;
int mul(int x,int y)
{
//local variable
int result;
//assigning x and y to local variable
int num1 = x;
int num2 = y;
result = num1*num2;
return result;
}
}
public class Main
{
public static void main (String[] args)
{
multiply m = new multiply();
System.out.println("multiplication of 3 and 5 is " + m.mul(5,3));
//we have assigned x and y to local variable so we can't access the value of x and y outside method
System.out.println("num1 = " + m.num1 + " num2 = " + m.num2);
}
}