Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

76 HOUR 6:Using Strings to Communicate


Workshop
The followingquestions test your knowledge of the care and feeding of a string.

Quiz



  1. My friend concatenates. Should I report him to the authorities?
    A. No. It’s only illegal during the winter months.
    B. Ye s ,but not until I sell the story to TMZ.com first.
    C. No. All he’s doing is pasting two strings together in a program.

  2. Why is the word Stringcapitalized,whereas intand others are not?
    A. Stringis a full word,but intain’t.
    B. Like all objects that are a standard part of Java,Stringhas a
    capitalized name.
    C. Poor quality control at Oracle.

  3. Which of the following characters puts a single quote in a string?
    A.
    B. \’
    C. ‘


Answers



  1. C.Concatenation is just another word for pasting,joining,melding,or oth-
    erwise connecting two strings together. It uses the +and+=operators.

  2. B.The types of objects available in Java are all capitalized,which is the
    main reason variable names have a lowercase first letter. It makes it
    harder to mistake them for objects.

  3. B.The single backslash is what begins one of the special characters
    that can be inserted into strings.

Free download pdf