Compsci 101 lecture 18 revision 2 76 complete the

This preview shows page 1 - 2 out of 2 pages.

CompSci 101 Lecture 18 - Revision 2 76. Complete the method, getMaxArray(), which is passed two int arrays as parameters. Both the parameter arrays have the same number of elements. The method creates a new array of the same size as the parameter arrays and fills each element of the new array with the maximum of the two corresponding elements of the parameter arrays. For example, executing the following code with the completed method: int[] nums1 = {13, 18, 49, 9, 51, 25, 23, 4 }; int[] nums2 = {33, 23, 41, 9, 17, 51, 13, 45 }; int[] maxA = getMaxArray(nums1, nums2); printArray(maxA); gives the output: maxA: 33, 23, 49, 9, 51, 51, 23, 45 } private int[] getMaxArray(int[] a, int[] b){ int[] maxA = } 77. Complete the compareArrays() method below. This method is given two arrays of integers as parameters and it should compare the contents of the two arrays. If the two arrays are the same size, and contain exactly the same values in the same order, then the method should return true . In all other cases, the method should return false . private boolean compareArrays(int[] a, int[] b){ } 78. Consider the Elevator class as defined below: public class Elevator { private int numFloors; private int currentFloor; public Elevator(int height) { numFloors = height; currentFloor = 0; } public void moveUp() { if (currentFloor < numFloors - 1) { currentFloor++; } } public String toString() { return "[" + currentFloor + "]"; } } What output is produced by the following code?
Image of page 1

Subscribe to view the full document.

Image of page 2
You've reached the end of this preview.
  • Summer '12
  • AdrianaFerraro
  • Method, Subroutine, private int, Mutator method

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern