Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Methods with parameters and return values help

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Methods with parameters and return values help

    Not really sure how to do this one. Appreciate any help:

    What is the output of the following program? Show your reasoning by including tables that illustrate how the values of the variables change over time, following the approach shown in Exercise 5 of Lab 4.
    public class TracingMethodCalls {
    public static int compute(int x, int y) {
    x += 3;
    y = 2*y - x;
    System.out.println(x + " " + y);
    return x;
    }

    public static void main(String[] args) {
    int x = 1;
    int y = 3;
    x = compute(x, y);
    System.out.println(x + " " + y);
    compute(y, y);
    System.out.println(x + " " + y);
    y = 3 + 4 * compute(y, x);
    System.out.println(x + " " + y);
    }
    }


  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    70
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Default Re: Methods with parameters and return values help

    What specifically are you having trouble with? Have you tried running the code to see what happens?

Similar Threads

  1. What is wrong with function return values
    By Shivafeb17 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 20th, 2013, 09:55 PM
  2. issue with return values stuck at 0
    By dendoc01 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 4th, 2013, 06:00 PM
  3. how to get return values from a button to main program.
    By harshilshah in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 5th, 2013, 08:17 AM
  4. [SOLVED] Return all values in an ArrayList from a method
    By IanSawyer in forum Collections and Generics
    Replies: 1
    Last Post: March 28th, 2012, 09:53 AM
  5. Need help my values wont return
    By sajeed in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 7th, 2012, 08:46 AM

Tags for this Thread