Exam 7: Characters, Strings and the Stringbuilder

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

​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.8/5
(43)

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

(Multiple Choice)
4.8/5
(38)
Match each term with the correct statement below.
Premises:
Length of a buffer
Responses:
insert()
buffer.
String variable.
Correct Answer:
Verified
Premises:
Responses:
Length of a buffer
insert()
(Matching)
4.8/5
(36)

How can you use String methods to change the case of a string? Provide an example.

(Essay)
4.7/5
(37)

A StringBuilder object contains a memory block called a _____, which might or might not contain a string.

(Multiple Choice)
4.8/5
(43)

String example1 = ""; String example2 = null; String example3; There is an important difference between empty String s and null String s. Explain the differences and why it is important when making String comparisons.

(Essay)
4.9/5
(36)

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

(True/False)
4.8/5
(41)

When you compare String s with the == operator, you are comparing their values, not their memory addresses.

(True/False)
4.8/5
(42)

The ____ method and the  startsWith()  method each take a  String  argument and return  true  or  false  if a  String  object does or does not end or start with the specified argument, respectively.

(Multiple Choice)
5.0/5
(34)

The creators of Java chose ____ characters as the "extra" length for a StringBuilder object.

(Multiple Choice)
4.8/5
(37)

The ____ method allows you to replace all occurrences of some character within a String .

(Multiple Choice)
4.8/5
(35)
Match each term with the correct statement below.
Premises:
A memory block
Responses:
String variable.
concatenation
anonymous object
Correct Answer:
Verified
Premises:
Responses:
A memory block
String variable.
(Matching)
4.9/5
(44)

What is a wrapper and why would you use it?

(Essay)
4.9/5
(34)

import javax.swing.JOptionPane; public class Practice {     public static void main(String[] args)     {      String fullName;      char firstLetter; ____ ____     } } Accepting a String from a user is common practice. Using the above code, write the statements to accept a String response from a user. Prompt the user with "Enter your name". Then use the charAt() method to extract the first character of the String .

(Essay)
4.7/5
(35)

The  String  class ____ method is similar to the  equals()  method. As its name implies, this method does not consider case when determining if two  String s are equivalent.

(Multiple Choice)
4.9/5
(41)
Match each term with the correct statement below.
Premises:
Appending strings
Responses:
concatenation
setLength()
String variable.
Correct Answer:
Verified
Premises:
Responses:
Appending strings
concatenation
(Matching)
4.8/5
(40)
Match each term with the correct statement below.
Premises:
Takes two integer arguments: a start position and an end position
Responses:
anonymous object
String variable.
immutable
Correct Answer:
Verified
Premises:
Responses:
Takes two integer arguments: a start position and an end position
anonymous object
(Matching)
4.8/5
(34)

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.8/5
(43)

How is the String class equalsIgnoreCase() method like the equals() method and how would you use it? Give an example.

(Essay)
4.9/5
(37)

  In the above code, two strings are evaluated using the equivalency operator. Why can this be a problem, and what other methods are offered by Java for working with characters and strings? In the above code, two strings are evaluated using the equivalency operator. Why can this be a problem, and what other methods are offered by Java for working with characters and strings?

(Essay)
4.7/5
(45)
Showing 41 - 60 of 82
close modal

Filters

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