Docsity

Lab 2: Strings, Strings, Strings - Software Engineering I | CSI 3471, Lab Reports of Software Engineering

Toggle sidebar
bg1
CSI 3471 Name ___________________________
Lab 2
1 of 2 Corrected 1/31/2008
Lab 2: Strings, Strings, Strings
Part 2
1. Copy project Lab2 into your Eclipse workspace. You can find it at
//ProfData/Grabow/csi3471/Labs/. Then compile and execute the code. You will
see output organized according to sections, with several fragment outputs
identified in each section
2. Use the output to look over your answers from Part 1. For each correct answer,
place a check mark. For each incorrect answer, write the correct answer next to
your initial answer. (You will be given credit for all of your answers from Part 1
as long as you provide the correct answer during Part 2.) Do not erase any
incorrect answers.
3. Once you have corrected your answers, please answer the following questions in
the space provide. When you are finished turn in both Part 1 and Part 2 to the
instructor.
a. What is the difference between the “==” operator and the “equals”
operator?
b. In fragment A.4, which object owns the compareTo function?
c. When startsWith takes two parameters, the 2nd parameter represents a
“position”. Is it possible for the position value to be negative?
d. Can the endsWith operation take more than one parameters? See the Java
documentation.
pf2

Partial preview of the text

Download Lab 2: Strings, Strings, Strings - Software Engineering I | CSI 3471 and more Lab Reports Software Engineering in PDF only on Docsity!

CSI 3471 Name ___________________________ Lab 2

1 of 2 Corrected 1/31/

Lab 2: Strings, Strings, Strings

Part 2

  1. Copy project Lab2 into your Eclipse workspace. You can find it at //ProfData/Grabow/csi3471/Labs/. Then compile and execute the code. You will see output organized according to sections, with several fragment outputs identified in each section
  2. Use the output to look over your answers from Part 1. For each correct answer, place a check mark. For each incorrect answer, write the correct answer next to your initial answer. (You will be given credit for all of your answers from Part 1 as long as you provide the correct answer during Part 2.) Do not erase any incorrect answers.
  3. Once you have corrected your answers, please answer the following questions in the space provide. When you are finished turn in both Part 1 and Part 2 to the instructor.

a. What is the difference between the “==” operator and the “equals” operator?

b. In fragment A.4, which object owns the compareTo function?

c. When startsWith takes two parameters, the 2nd^ parameter represents a “position”. Is it possible for the position value to be negative?

d. Can the endsWith operation take more than one parameters? See the Java documentation.

CSI 3471 Name ___________________________ Lab 2

2 of 2 Corrected 1/31/

e. For fragment B.2: i. Explain the difference between the two different calls to regionMatches, one with four parameters and the other with five.

ii. Why does the second call return true?

f. For fragment C.2, how is lastIndexOf different from indexOf?

g. For fragment C.3, where does the indexOf start to look for a match?

h. For fragment C4, where does the lastIndexOf start to look for a match?

i. What happens when indexOf or lastIndexOf does not find a match?