String Practice
Suppose that s is the String "slaphappy" and
that t is the String "ap". What are the values of the
following expressions?
-
s.indexOf("smack")
- -1
- 0
- 10
- unknown
- error
-
s.indexOf(t)
- -1
- 0
- 1
- 2
- 3
- unknown
- error
-
s.indexOf(s.substring(1,4))
- -1
- 0
- 1
- 2
- 3
- unknown
- error
-
s.substring(0,t.length()) + s.substring(0,s.length())
- 0
- "apslaphappy"
- "slaphappy"
- "slslaphappy"
- "slslap happy"
- unknown
- error
Jeffrey R.N. Forbes
Last modified: Wed Sep 28 13:12:54 EDT 2005