FryzDog Posted March 1, 2004 Share Posted March 1, 2004 Can someone help me out..what would the output of this code be........ class Question4 { private int x, y, z; public void start() { int x, y; setup(); x = y = 10; modify(x, y); printout(); } private void setup() { x = 100; y = 200; z = 300; } private void modify(int x, int y) { z = x + y; x = z; y = 2 * z; } private void printout() { System.out.println("x+ x); System.out.println("y+ y); System.out.println("z+ z); } } class Q4Main { public static void main(String[] args) { Question4 q4; q4 = new Question4(); q4.start(); } } Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/ Share on other sites More sharing options...
0 clonk Posted March 1, 2004 Share Posted March 1, 2004 It looks to me like this is the output: x = 20 y = 40 z = 20 Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1780920 Share on other sites More sharing options...
0 PseudoRandomDragon Posted March 1, 2004 Share Posted March 1, 2004 You need to get a compiler. Are you doing this in Java? Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1780927 Share on other sites More sharing options...
0 FryzDog Posted March 1, 2004 Author Share Posted March 1, 2004 yes it is for java...and what would be a good yet FREE compiler.... Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782069 Share on other sites More sharing options...
0 +chorpeac MVC Posted March 1, 2004 MVC Share Posted March 1, 2004 go to http://www.jcreator.com/ They have a good one that is free for 30 days or so. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782143 Share on other sites More sharing options...
0 Gism0 Posted March 1, 2004 Share Posted March 1, 2004 sparky789er said: yes it is for java...and what would be a good yet FREE compiler.... javac ! get the JDK from http://sun.java.com/ Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782170 Share on other sites More sharing options...
0 HellBender Posted March 1, 2004 Share Posted March 1, 2004 Gism0 said: javac ! get the JDK from http://sun.java.com/ The SDK :p Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782198 Share on other sites More sharing options...
0 John Veteran Posted March 1, 2004 Veteran Share Posted March 1, 2004 Gism0 said: javac ! get the JDK from http://sun.java.com/ I think you meant http://java.sun.com :huh: Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782215 Share on other sites More sharing options...
0 PseudoRandomDragon Posted March 1, 2004 Share Posted March 1, 2004 You are probably confused by now. Jcreator provides a nice interface for you to write programs. Really, you could do it in notepad, but it is a lot nicer and easier with Jcreator. However, Jcreator itself doesn't compile the programs, you need SDK (Sun development kit) installed for that. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782438 Share on other sites More sharing options...
0 HellBender Posted March 1, 2004 Share Posted March 1, 2004 AFAIK, Jcreator includes an integrated SDK, so you can compile programs from within Jcreator without needing to download the SDK seperately. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782591 Share on other sites More sharing options...
0 +chorpeac MVC Posted March 1, 2004 MVC Share Posted March 1, 2004 Thanks hellbender, you beat me to it! :D Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782605 Share on other sites More sharing options...
0 akeller87 Posted March 1, 2004 Share Posted March 1, 2004 Textpad is a good compiler Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782688 Share on other sites More sharing options...
0 Kestrel Posted March 1, 2004 Share Posted March 1, 2004 I would point out that this is the THIRD question from the original poster; looks like he's just doing his homework here. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782813 Share on other sites More sharing options...
0 HellBender Posted March 1, 2004 Share Posted March 1, 2004 akeller87 said: Textpad is a good compiler Textpad does not have a compiler built in, it uses javac from the SDK!! You have to have the SDK installed seperately to be able to compile from Textpad /me gives up Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1782823 Share on other sites More sharing options...
0 PseudoRandomDragon Posted March 2, 2004 Share Posted March 2, 2004 Kestrel said: I would point out that this is the THIRD question from the original poster; looks like he's just doing his homework here. I noticed that too, which is why I suggested him getting his own compiler. If he keeps doing it, then he is going to get it from us. I have a feeling that once he realizes how hard programming can be, he is going to quit. Just a feeling though. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1783309 Share on other sites More sharing options...
0 MrA Posted March 2, 2004 Share Posted March 2, 2004 Sun's java compiler isn't the only one out there. I use the GNU java compiler, but only cause I'm crazy. Wait, I'm not crazy, I just had problems installing sun's compiler. Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1783966 Share on other sites More sharing options...
0 Steven Posted March 2, 2004 Share Posted March 2, 2004 Borland JBuilder X Foundation is a FREE IDE + Compiler etc..etc... Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1783977 Share on other sites More sharing options...
0 Gism0 Posted March 2, 2004 Share Posted March 2, 2004 haha sorry guys i'm off my head - had the flu for the past week, tempreture is sky high Link to comment https://www.neowin.net/forum/topic/144698-help-me-with-the-output/#findComment-1785162 Share on other sites More sharing options...
Question
FryzDog
Can someone help me out..what would the output of this code be........
class Question4 {
private int x, y, z;
public void start() {
int x, y;
setup();
x = y = 10;
modify(x, y);
printout();
}
private void setup() {
x = 100;
y = 200;
z = 300;
}
private void modify(int x, int y) {
z = x + y;
x = z;
y = 2 * z;
}
private void printout() {
System.out.println("x+ x);
System.out.println("y+ y);
System.out.println("z+ z);
}
}
class Q4Main {
public static void main(String[] args) {
Question4 q4;
q4 = new Question4();
q4.start();
}
}
Link to comment
https://www.neowin.net/forum/topic/144698-help-me-with-the-output/Share on other sites
17 answers to this question
Recommended Posts