Question: 4. Consider the following method do Task public static Boolean doTask(intll arr) boolean found true; for(int i0; karrlength;i++ found-found && (arr[i] % 2=1); return found;

 4. Consider the following method do Task public static Boolean doTask(intll

4. Consider the following method do Task public static Boolean doTask(intll arr) boolean found true; for(int i0; karrlength;i++ found-found && (arr[i] % 2=1); return found; Which of the following statements is true about method doTask? Method doTask returns true if all elements in its array parameter a Method doTask returns true if all elements in its array parameter arr are odd, false otherwise. Method doTask returns true if all elements in its array paramete Method d Method doTask will always return true. rr are even, false otherwise. a. b. c. d. e. r arr are positive, false otherwise. oTask returns true if all elements in its array parameter arr are equal to 1, false otherwise. 5. Which statement below is true about preconditions? Why? a. It is the method's responsibility to check that its precondition is satisfied b. A precondition describes what is returned by the method. c. A precondition describes the parameters and their restrictions in order for the method to function as intended. d. A precondition describes how a method is implemented. e. If a precondition is not satisfied, the compiler will automatically throw an exception. a. 1 6. Consider the problem of modeling a Point class. A Point object represents a point in the rectangular coordinate 2 b. c. d. 7 e. 24 system. A Point object has an x-coordinate and a y-coordinate. Which of the following methods would not be a good choice for a cohesive public interface for this class? Why? a. getx) b. setY(int newY) c. distancefromOrigin(); d. distanceFrom(Point a); e. perimeter(Point a, Point b, Point c): 2. A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!