Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

Which of the following shows the header for a method that will accept any number of int values? public static int add(int x) public static int add(int x, int y, int... z) public static int add(int...x) public static int add(int[] x)

OpenStudy (anonymous):

@MDoodler

OpenStudy (anonymous):

actually here I just took a screenshot of everything I have here.

OpenStudy (anonymous):

what one you think?

OpenStudy (anonymous):

OpenStudy (anonymous):

I think it's the 3rd one

OpenStudy (anonymous):

for the one you asked about

OpenStudy (anonymous):

@bibby

OpenStudy (anonymous):

@hartnn

OpenStudy (lyrae):

Q4 is one of those tricky questions with several possible answers due to poor formulation. d) isn't technically wrong because passing an int array and dealing with it properly will allow the method to "... accept any number of int values ...". In this question they're however asking for a "... header for a method that will accept any number of int values ..." which means what they're really asking for is a header that accepts a variable amount of arguments. That feature is called varargs and you can read about the details in the links http://stackoverflow.com/questions/2330942/java-variable-number-or-arguments-for-a-method http://docs.oracle.com/javase/7/docs/technotes/guides/language/varargs.html

OpenStudy (woodrow73):

Nice! I haven't heard of that one before.. it'll come in handy.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!