0

Tis also no output

//Methods with Reference arguments class A { int x; void add() { System.out.println(" X : "+x); } } class Sample { A o1; void test(A o2) { this.o1=o2; o2.add(); } } class Demo3 { public static void main(String aa[]) { A ss1=new A(); ss1.x=5000; new Sample().test(); } }

4th Dec 2016, 5:46 PM
Kansi Ram
Kansi Ram - avatar
3 Answers
+ 2
your version should not even compile. try new Sample().test(ss1);
4th Dec 2016, 6:22 PM
Roland
+ 2
Roland's correct. Output is 5000 with the change.
4th Dec 2016, 7:43 PM
Kirk Schafer
Kirk Schafer - avatar
0
ref is passed in tis method ah roland
5th Dec 2016, 4:24 AM
Kansi Ram
Kansi Ram - avatar