Home Java Java-tips Data Strings Q-fi-string-exercises String Exercises 1 - Answers

Ask Questions?

View Latest Questions

Advertisement


 
 

String Exercises 1 - Answers
Posted on: July 26, 2006 at 12:00 AM
Answers to the String Exercises 1.

Java: String Exercises 1 - Answers

Answers to the String Exercises 1.

  1. 3 -- s refers to exactly the same string as a.
  2. ERROR -- t is a local variable, and it must be assigned a value first.
  3. "1abc" -- + means concatenation here because an operand is type String
  4. "ABC"
  5. 4
  6. 6
  7. "mo"
  8. false -- the string is "3abc"
  9. true -- they are the same string (== to test for same objects)
  10. true -- Use .equals to test for same value. Here it is likely that a.substring(1,3) == "bc" is false.
Copyleft 2003 Fred Swartz MIT License, Last update: 2003-11-01
Advertisement


DMCA.com