Question
6. (6 points) Carefully explain to a new Java programmer why all sorting methods that have a basic array as a parameter also have a
6. (6 points) Carefully explain to a new Java programmer why all sorting methods that have a basic array as a parameter also have a void return type. (Use complete sentences with correct grammar and spelling. Make significant and relevant points avoid trivial, terse answers.)
7. (6 points) Consider the following recursive method foo.
public static int foo(int x) throws Exception { if(x <= 0)
throw new Exception("Input must be positive."); if(x == 1)
return 1; return foo(x);
} Which of the following is true of foo? Fill in exactly one choice.
foo is correct and does not do redundant work foo is correct but is inefficient due to redundant work
foo is incorrect
If you did not select the first choice, briefly describe how to modify foo such that it is true.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started