Preview

E-Commerce Exercise

Better Essays
Open Document
Open Document
1068 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
E-Commerce Exercise
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

You May Also Find These Documents Helpful

  • Good Essays

    Onetop Master

    • 439 Words
    • 2 Pages

    Which of the following is a correct call to a method declared as public static void aMethod(char code)?…

    • 439 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Coding: Questions

    • 2042 Words
    • 18 Pages

    In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies.…

    • 2042 Words
    • 18 Pages
    Good Essays
  • Powerful Essays

    French Ab Past Paper

    • 1485 Words
    • 8 Pages

    QUESTION AND ANSWER BOOKLET – INSTRUCTIONS TO CANDIDATES • • • • • • • Write your session number in the boxes above. Do not open this booklet until instructed to do so. This booklet contains all the Paper 1 questions (Text handling and written response). Refer to the Text Booklet which accompanies this booklet. Answer all of the questions in the spaces provided. Each text handling question is allocated [1 mark] unless otherwise stated. The written response is allocated [10 marks].…

    • 1485 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    • String, can store any number of characters. String will allocate the memory at runtime which is also called as dynamic memory allocation, will allocate the memory as per the size of the string. Strings cannot be declared using parameters as the memory of allocation is dynamic.…

    • 1366 Words
    • 6 Pages
    Good Essays
  • Best Essays

    Thinkcspy CEP Textbook

    • 131187 Words
    • 952 Pages

    2.10 Input . . . . . . . . . . . . . . .…

    • 131187 Words
    • 952 Pages
    Best Essays
  • Satisfactory Essays

    Java Test

    • 469 Words
    • 2 Pages

    Q3. “ X extends Y “ is correct if and only if X is a class and Y is an interface.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Hrm Dsdvsd

    • 2401 Words
    • 10 Pages

    contain a string, a number, an enumeration symbol or a list. A list item may be any of the…

    • 2401 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    3. Create a program that determines if the input numbers is a magic number (143) which is equivalent to the magic word: “I LOVE YOU”, if it is equivalent, then display the message.”Right” otherwise display the message. ”Wrong”.…

    • 1323 Words
    • 6 Pages
    Good Essays
  • Good Essays

    Array Sample Program

    • 968 Words
    • 4 Pages

    For example, an array to contain 5 integer values of type int called billy could be represented like this:…

    • 968 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Practice Assignment 1

    • 2761 Words
    • 26 Pages

    This guided example, will not provide a solution for programming assignment 1. However, it will guide you…

    • 2761 Words
    • 26 Pages
    Powerful Essays
  • Satisfactory Essays

    C# String Functions

    • 325 Words
    • 2 Pages

    7. Insert - Returns a new string in which a specified string is inserted at a specified index position in this instance.…

    • 325 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    It Theory Question Paper

    • 2478 Words
    • 10 Pages

    Various options are given as possible answers to the following questions. Choose the correct answer and write only the capital letter (A-D) in print next to the question number (1.1-1.10); e.g. 1.11 C.…

    • 2478 Words
    • 10 Pages
    Satisfactory Essays
  • Better Essays

    L215 Report

    • 3708 Words
    • 15 Pages

    In any programming language, there are several data types that are available for programmers to use, such as integers, floating point numbers, strings or characters. Many applications need more complicated structures of data that can be added on a program-to-program basis; hence, the notion of data abstraction.…

    • 3708 Words
    • 15 Pages
    Better Essays
  • Satisfactory Essays

    notes on arrays

    • 326 Words
    • 2 Pages

    Named integer constants can be defined as members of an enumeration. enum keyword {ASM, AUTO, BREAK}; keyword key; Krishna M. Singh, Department of Mechanical & Industrial Engineerig, IIT-Roorkee 2 Derived Data Types Address Types References Pointers Powerful, but difficult to master Simulate pass-by-reference Close relationship with arrays and strings…

    • 326 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Introduction to programming 1 Tutorial letter 102 for COS1511 Solutions to exercises in the Study Guide…

    • 289 Words
    • 2 Pages
    Satisfactory Essays

Related Topics