Q:

Java - Method with Parameter

0

This Program is used to demonstrate the Method with Parameter concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class fun1 
{ 
int a, b; 

void calc(int x,int y) 
{ 
a = x; 
b = y; 
} 

void add() 
{ 
System.out.println("\nAddition :"+(a+b)); 
} 

void sub() 
{ 
System.out.println("\nSubtraction :"+(a-b)); 
} 

void mul() 
{ 
System.out.println("\nMultiplication :"+(a*b)); 
} 

void div() 
{ 
System.out.println("\nDivision :"+(a/b)); 
} 

void rem() 
{ 
System.out.println("\nModules :"+(a%b)); 
} 

public static void main(String arg[]) 
{ 
fun1 x; 
x = new fun1(); 

x.calc(10,3); 

x.add(); 
x.sub(); 
x.mul(); 
x.div(); 
x.rem(); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now