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 3 of 3

Thread: Multiple choice help

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

    Default Multiple choice help

    Which of the following can be used to replace the body of mystery so that mystery will return the same result for all values of y?

    public static int mystery(int y)
    {
    y = 2 * y + y;
    y = 2 * y + y;
    return y;
    }

    A) return 9 * y;
    B) return 7 * y;
    C) return y;
    D) return 3 * y;
    E) return 4 * y;

  2. #2
    Member
    Join Date
    Aug 2017
    Location
    Northern Ireland
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Multiple choice help

    What do you think is the correct answer? And why?
    Tim Driven Development

  3. #3
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: Multiple choice help

    This is what you'd call an identity or properties of idenity. I cannot figure the value of Y. Does the body of mystery do anything? return y, does just that, the value.

Similar Threads

  1. need help with simple multiple choice
    By levitron18 in forum Other Programming Languages
    Replies: 2
    Last Post: June 17th, 2014, 10:43 AM
  2. Is scanner the right choice?
    By Badformat in forum Java Theory & Questions
    Replies: 1
    Last Post: January 20th, 2014, 04:02 PM
  3. Java, A good choice?
    By BillnTexas in forum Java Theory & Questions
    Replies: 7
    Last Post: November 16th, 2010, 11:05 AM
  4. Which interface gives more control on serialization of an object?
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 16th, 2009, 10:17 AM
  5. Replies: 2
    Last Post: May 16th, 2009, 05:23 AM

Tags for this Thread