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: Array question - confused by answer

  1. #1
    Member
    Join Date
    Feb 2013
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Array question - confused by answer

    Hello All,

    I recently took a quiz and I am confused by the correct answer. Can someone please explain the answer to me? Thank you so much!

    You have two arrays named b and c. You call a static method that swaps the value in component k of one array with the value in component k of the other array. This swap method does not mention any variable declared outside the method except its parameters. Which of the following method calls could possibly accomplish this?

    Correct answer: swap (c, b, k);

    Any help would be appreciated. Thanks!


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    939
    Thanks
    6
    Thanked 202 Times in 178 Posts

    Default Re: Array question - confused by answer

    Do you see how swap() might have been implemented so that it can be called with swap(c,b,k)?

    Presumably the other options did not send swap() enough (or the right kind of) "information" for it to do its job. For example it is vital that swap() have the parameter k - it is not enough to send it the values c[k] and b[k]. Again, trying to implement something called with swap(c[k], b[k]) will help reveal why.

  3. #3
    Member
    Join Date
    Feb 2013
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Array question - confused by answer

    Thank you so much for clearing that up for me!

Similar Threads

  1. [SOLVED] please answer this question,tq
    By suganti selvaraj in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 5th, 2013, 11:50 PM
  2. How to show a question again when a wrong answer is entered?
    By Henk in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2012, 01:02 PM
  3. please answer some basic question
    By togaurav in forum Java Theory & Questions
    Replies: 5
    Last Post: April 16th, 2011, 07:58 AM
  4. Really Quick n00b question, should take three seconds to answer
    By joeschmidt45 in forum Java Theory & Questions
    Replies: 4
    Last Post: February 24th, 2011, 04:23 AM
  5. [SOLVED] Begginer Question please help ASAP! (Easy to Answer)
    By Bagzli in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2010, 09:00 PM