Exam 7: Characters Strings and the Stringbuilder

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

StringBuilder greeting = new StringBuilder("Welcome"); Use the append() method to add the characters "home" to the end of the StringBuilder object created above.

Free
(Essay)
5.0/5
(44)
Correct Answer:
Verified

greeting.append(" home");
(Be sure that the String in double quotes has a blank space at the start. Otherwise, the String s "Welcome" and "home" will be appended without a blank space.)

String oneStr = "Welcome Jim" String twoStr = "Welcome Joe" Given the lines of code above, which of the following regionMatches() expressions will result in a value of true ?

Free
(Multiple Choice)
4.7/5
(36)
Correct Answer:
Verified

B

The ____________________ method requires an integer argument that indicates the position of the character at that position, starting at 0.

Free
(Short Answer)
4.9/5
(40)
Correct Answer:
Verified

charAt()

Any string value that is input into a program can be used in arithmetic operations.

(True/False)
4.7/5
(35)

The ____ method lets you add characters at a specific location within a StringBuilder object.

(Multiple Choice)
4.8/5
(41)

A(n) ____ is a variable that holds a memory address.

(Multiple Choice)
4.7/5
(43)

A String variable name is not a simple data type.

(True/False)
4.9/5
(38)

Explain what is needed to declare a String variable and provide an example.

(Essay)
4.9/5
(29)

When you must determine whether a String is empty, it is more efficient to compare its length to 0 than it is to use the equals () method.

(True/False)
4.8/5
(39)

When working with String s, it is necessary to explicitly set a String to null .

(True/False)
4.8/5
(31)

String s  and other objects that can't be changed are said to be immutable. What does this mean and how does it relate to values held in memory addresses?

(Essay)
4.8/5
(33)

In a compareTo() method, programmers often do not need specific return values but want to determine if a value is positive or negative.

(True/False)
4.9/5
(28)

What is the purpose of the replace() method? Provide an example.

(Essay)
4.7/5
(46)

Give a code example of using the equivalence operator ("==") to compare the addresses of two strings where the comparison will result in the value true . The example should produce output indicating the strings have the same value.

(Essay)
4.7/5
(30)

A ____ is a class for storing and manipulating changeable data that is composed of multiple characters.

(Multiple Choice)
4.8/5
(34)

You can tell that the equals() method takes a ____ argument because parentheses are used in the method call.

(Multiple Choice)
4.9/5
(34)

When you declare a variable of a basic, primitive type, such as int x = 10; , the memory address where x is located holds the ____.

(Multiple Choice)
4.7/5
(26)

A(n) ____ comparison is based on the integer Unicode values of the characters.

(Multiple Choice)
4.7/5
(38)

If you try to use an index that is less than 0 or less than the index of the last position in the StringBuilder object, you cause an error known as an exception and your program terminates.

(True/False)
4.7/5
(41)

When the String class ____ method is used to compare two String s, it provides additional information to the user in the form of an integer value.

(Multiple Choice)
4.9/5
(43)
Showing 1 - 20 of 68
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)