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

Info iconThis 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) {
Background image of page 1

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

View Full DocumentRight 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)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/14/2010 for the course CS 15-100 taught by Professor Dave during the Spring '08 term at Carnegie Mellon.

Page1 / 3

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online