Exam 7: Characters, Strings and the Stringbuilder

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

The methods islowerCase() and toLowerCase() perform the same tasks.

Free
(True/False)
4.8/5
(34)
Correct Answer:
Verified

False

StringBuilder greeting = new StringBuilder("Day 1"); Using the above StringBuilder , create a setCharAt() method that will change the "1" to a "2" in the String "Day 1" . Explain how the setCharAt() method operates.

Free
(Essay)
4.8/5
(34)
Correct Answer:
Verified

greeting.setCharAt(4, '2'); To alter just one character in a StringBuilder , you can use the setCharAt() method, which allows you to change a character at a specified position within a StringBuilder object. This method requires two arguments: an integer position and a character. In the phrase "Day 1", the greeting.setCharAt(4, '2'); changes the value 1 to 2.

Match each term with the correct statement below.
Premises:
Change the length of a string in a StringBuilder object
Responses:
substring().
append().
anonymous object
Correct Answer:
Verified
Premises:
Responses:
Change the length of a string in a StringBuilder object
substring().
Free
(Matching)
4.8/5
(38)
Correct Answer:
Verified

Match each term with the correct statement below.
Premises:
Class or object that wraps around a simpler element
Responses:
insert()
immutable
concatenation
Correct Answer:
Verified
Premises:
Responses:
Class or object that wraps around a simpler element
insert()
(Matching)
4.9/5
(35)

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

(Essay)
4.8/5
(34)

The method header of the equals() method within the String class is ____.

(Multiple Choice)
4.9/5
(28)

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
(42)

The ____ class contains standard methods for testing the values of characters.

(Multiple Choice)
4.8/5
(34)

The ____ method takes a String argument and returns its double value.

(Multiple Choice)
4.9/5
(39)

Describe how a string is a reference and how a string comparison is done.

(Essay)
4.8/5
(33)

Consider the statement: int anInt = Integer.parseInt("649"); You can tell that  parseInt() is a(n) ____ method because you use it with the class name and not with an  object.

(Multiple Choice)
4.9/5
(37)

What is the purpose of the substring() method and how do you use it?

(Essay)
4.7/5
(30)

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

(Multiple Choice)
4.9/5
(29)

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

(Multiple Choice)
4.9/5
(28)

yourCounty = "perry"; yourCounty.equals("Perry"); yourCounty.equalsIgnoreCase("Perry"); Using the above statements, what value will be returned by the equals() method? What will be the value of the equalsIgnoreCase() method? Explain how the equalsIgnoreCase() method can be useful when users type responses to prompts in programs.

(Essay)
4.9/5
(43)

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
(43)

What happens when you increase a StringBuilder object's length to be longer than the string it holds?​ What happens if you set the length of a string to be shorter than the string it contains?

(Essay)
4.7/5
(38)

A String variable name is not a simple data type.

(True/False)
4.9/5
(34)

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

(Essay)
4.8/5
(39)

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 ?

(Multiple Choice)
4.7/5
(43)
Showing 1 - 20 of 82
close modal

Filters

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