Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Quiz

The following questions will test your knowledge of the care and feeding of a string.

Questions

  1. My friend concatenates. Should I report him to the authorities?

    1. No. It's only illegal during the winter months.

    2. Yes, but not until I sell the story to Real TV first.

    3. No. All he's doing is pasting two strings together in a program.

  2. Why is the word String capitalized, while int and others are not?

    1. String is a full word, but int ain't.

    2. Like all objects in Java, String has a capitalized name.

    3. Poor quality control at Sun Microsystems.

  3. Which of the following characters will put a single quote in a string?

    1. <QUOTE>

    2. \'

    3. '

Answers

  1. c. Concatenation is just another word for pasting, joining, melding, or otherwise 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.

  • + Share This
  • 🔖 Save To Your Account