
hi this is my code
class Test {
void meth(int i, int j) {
i *= 2;
j /= 2;
System.out.println("a=" +i);
System.out.println("b=" +j);
}
}
public class CallByValue1 {
public static void main(String args[]) {
Test ob = new Test();
int a = 15, b = 20;
System.out.println("a and b before call: "
+ a + " " + b);
ob.meth(a, b);
System.out.println("a and b after call: "
+ a + " " + b);
}
}
why these lines
System.out.println("a=" +i);
System.out.println("b=" +j);
print a=30 & b=10 As changes made to the parameter of the subroutine have no effect on the argument plz clear my doubts soon.

In the method you have multiplied the number by 2 and in the main method you have declared two numbers a is 15 and b is 20.So when you have called the method meth() of Test class, the method takes the arguments 15 and 20 as a result it multiply the value of a i.e 15 by 2 and divide the value of b 20 by 2 to produce the output 30 and 10 respectively. This method is of void type and so does not have any return type. So the following code displays the values 15 and 20.
System.out.println("a and b after call: "+ a + " " + b);
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.