+ 1
Explanation for output of this java code..
4 Respostas
+ 2
Harsh Vyas because you are calling c2.sum(5) method
code c1=new code();
code c2=new code();
c1.harsh="blue";
==> c2.sum(5);
System.out.println(c1.harsh);
System.out.println(c2.sum(5));
+ 2
It don't prints 5 unless you call it through System.out.println() method.
+ 1
You are retrieveing feild and method of code class from code1
by creating object of code class. However you don't need two different objects instead you can we acess both of the variable and method from one single object.
code c1=new code();
c1.harsh="blue";
System.out.println(c1.harsh);
System.out.println(c1.sum(5));
0
But AMOGHA. A. K. Why this sop(c1.harsh); is printing harsh is blue instead of blue