E-Commerce Exercise

Topics: Data type, Subroutine, Java Pages: 4 (1068 words) Published: February 20, 2011
Characters, Strings, and the StringBuffer

Quick Quiz 1

1. As an object, a String variable name is not a simple data type. It is a(n) ____; that is, a variable that holds a memory address.

1. The ____ method of the Character class returns true if the argument is a digit (0–9) and false otherwise.

2. What is the value of result in the following program code? char aChar = 'C';
Boolean result = Character.isWhitespace(aChar);

Quick Quiz 2

1. True or False: The class String is defined in java.lang.String, which is automatically imported into every program you write.

2. Strings and other objects that can’t be changed are known as ____.

3. The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.

4. The ____ method requires an integer argument that indicates the position of the character that the method returns.

Quick Quiz 3

1. To convert a String to an integer, you use the Integer class, which is part of ____ and is automatically imported into programs you write.

2. A method of the Double class is the ____ method, which takes a String argument and returns its double value.

3. True or False: You can change the length of a String in a StringBuffer object with the setLength() method.

Class Discussion Topics

1. Why do you think Java provides primitive data types AND wrapper classes for them? Why not just one or the other?

2. Under what circumstances would you choose to use the String class? When would you use StringBuffer?

Additional Projects

1. Create a program that prompts the user to enter two Strings. Then display the Strings in alphabetical order. If the two Strings are equal, display a message that they are equal rather than printing them in alphabetical order.

2. In addition to the methods covered in this chapter, Java provides a number of classes used to convert and format...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • E Commerce Essay
  • E-commerce Essay
  • E-commerce Business Plan Essay
  • Essay on The E-Commerce Model of IKEA
  • e-commerce Essay
  • Essay about E-Commerce Services Market in China
  • E-commerce: Electronic Commerce and Implementation Essay
  • E Commerce Research Paper

Become a StudyMode Member

Sign Up - It's Free