Jump to content

DreamingCode

New Members
  • Posts

    3
  • Joined

  • Last visited

DreamingCode's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. public class FindInteger { int x = 10; int y = 20; int z = 30 ; int m1(int y, int z) { int x = 15; y = x + z; this.y = y + 10; IO.outputln("x: " + x + " y: " + y + " z: " + z); return y; } void m2( ) { int z=40; int y = m1 (x, x); if ( z < 50 ) { int x = 90; z = x + y; } x = x + y + z; IO.outputln("x: " + x + " y: " + y + " z: " + z); } public static void main(String[ ] args){ FindInteger q = new FindInteger( ); q.m2( ); IO.outputln("x: " + q.x + " y: " + q.y + " z: " + q.z); } } this is a full code of this particular class i wrote, however its giving me values which i dont agree with. It gives me x: 15 y:25 z: 10 x: 150 y:25 z: 115 x: 150 y:35 z: 30 i dont understand this.. why is z=10? also why is z=30 on the last line?
  2. wait so i dont get it, is it supposed to be x:15 y:25 z:10?
  3. public class FindInteger { int x = 10; int y = 20; int z = 30 ; int m1(int y, int z) { int x = 15; y = x + z; this.y = y + 10; IO.outputln("x: " + x + " y: " + y + " z: " + z); return y; } the output of this simple program i wrote gives x:15 y:25 z:10. My question is why is it giving me these values? Shouldnt it be giving me x:15 y:45 z:30?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.