Computer Science, asked by sharoanlukeshibu, 6 months ago

find the output of the following code in java:-
class test
{
int a;
int b;
void meth(int i,int j)
{
i*=2;
j/=2;
}
}
class output
{
public static void main(String[]args)
{
test obj=new test();
int a=10;
int b=20;
obj.meth(a,b);
System.out.println(a+" "+b);
}
}

Answers

Answered by piyushkumar2231
1

Answer:

The output will be 30

First add than increase

in second also

Answered by qwvilla
0

The output of the given program will be :

10 20

  • No changes will be reflected on the value of a and b.

  • This is because the variables a & b are passed by value.

  • Copy of their values is made on formal parameters of the method meth() i.e. i & j.

  • is made on formal parameters of the method meth() i.e. i & j. Therefore changes done on variables i & j are not reflected back on the original arguments.

  • the original arguments. Thus the values of a & b remain 10 & 20 respectively and do not change.

#SPJ3

Similar questions