{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

quiz11 - Name Dave's 15-100 Section M N O P April 8 2009...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Name: ____________________ Section: M N O P Dave's 15-100 April 8, 2009 Quiz 11 1. Consider the following code segment, which you should assume compiles and runs without error. data[3] = "hi"; data[4] = "bye"; backup = data; data[3] = data[4]; data[4] = data[3]; What is the final value of data[3] ? ____________________ What is the final value of data[4] ? ____________________ What is the final value of backup[3] ? ____________________ 2. Implement the addFirstAndLast method, which should return the sum of the first and last integer in the given array, as illustrated by the following examples: contents of array nums value returned by addFirstAndLast(nums) [9, 7] 16 [8, 7, 2] 10 [7, 5, 5, 6, 8] 15 public static int addFirstAndLast(int[] nums) {
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Reference: String Class boolean equals (String other) int length () String substring(int from, int to) Returns the substring beginning at from and ending at to-1 . String substring(int from) Returns substring(from, length()) . int indexOf(String s) Returns the index of the first occurrence of s . Returns -1 if not found.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ 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