Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Java Programming
Quiz 7: Characters, Strings, and the Stringbuilder
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
Short Answer
String greeting = "Welcome back"; Using the above statement, write the length() method that will return the length of the greeting String. Store the length in an integer named greetingLength.
Question 62
Essay
StringBuilder greeting = new StringBuilder("Welcome"); Create the append() method to add the characters "home" to the end of the StringBuilder object created above.
Question 63
Short Answer
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.
Question 64
Essay
String firstCompare = "Oak Maple Pine" String secondCompare = "spruce maple elm" firstCompare.regionMatches(false, 4, secondCompare, 7, 5) Using the above code, what will be the Boolean value after execution of the regionMatches statement? Explain how the Strings are compared using the regionMatches() method.
Question 65
Essay
String aName = "Michael" Using the above statement, write the length() method that will return the length of the aName String. What value will the length() method return when executed?
Question 66
Essay
String greeting = "Welcome Home"; Using the above String, create the String method to convert the greeting String to all uppercase. Likewise, create the String method to convert the greeting String to all lowercase.
Question 67
Essay
StringBuilder greeting = new StringBuilder("Welcome home "); phrase.insert(13, "Joe"); Using the above code and insert() method, describe how the phrase will appear after the code executes. How does the insert() method work?