Hi Eranga,

I have done this using only method, though the answer is correct but I am not sure whether the method can generalized.
Please find below is the code:-
Java Code:
public class AdMultiples {
  
    public static void main(String[] args) {
        Threed ob1 = new Threed();
 
        int iSumOf3 = 0;
        int iSumOf5 = 0;
        int iComIB = 0;
          
        iSumOf3 = ob1.Demo(0, 1000, 3);
        iSumOf5 = ob1.Demo(0, 1000, 5);
        iComIB = ob1.Demo(0, 1000,1);
        System.out.println("The sum is:=" + (iSumOf3 + iSumOf5 - iComIB));
    }
}
  
class Threed
{
 /*function Demo, finds multiples of numbers passed in
  * as arguments and also calculates the sum*/
 
	public int Demo(int iMin, int iMax, int iMultiple) {
        int iSum = 0;
        
        for (int index = iMin; index < iMax; index++) 
        {
            if (index % iMultiple == 0 && iMultiple !=1 ) 
            {
                iSum += index;
            }
            else if(iMultiple == 1 && index % 3 == 0 && index % 5 == 0)
            {
            	
                    iSum += index;
            }
          }
        
  
        return iSum;
        
    }
}
Btw the line in the code reduced to 41 :).

Thanks in advance.

Kind Regards,
Ankit