Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 10.11, Problem 10.11.6CP
Suppose s1 and s2 are given as fot tows:
StringBuilder s1 = new StringBuilder(“Java”);
StringBuilder s2 = new StringBuilder(“HTML”);
Show the value of s1 after each of the following statements. Assume the statements are independent.
a. s1.append(“ is fun”);
b. s1.append(s2);
c. s1.insert(2, “is fun”);
d. s1.insert(1, s2);
e. s1.charAt(2);
f. s1.length();
g. s1.deleteCharAt(3);
h. s1.delete(1, 3);
i. s1.reverse();
j. s1.replace(1, 3, “Computer”);
k. s1.substring(1, 3);
l. s1 .substring(2);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
B2. Convert the following JavaFX code segment of Lambda expression into an inner class.
Button btn = new Button("OK");
btn.setOnAction(e->{
System.out.println("Hello World!");
} );
Given the following:
strFirstName = “Java”
strLastName = “is fun!”
Write a statement that concatenates the two string values and assigns them to strFullName, so the new string appears as Java is fun!.
Briefly describe each of the following string object methods: TrimStart
Chapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 10.2 - Prob. 10.2.1CPCh. 10.3 - Is the BMI class defined in Listing 10.4...Ch. 10.4 - Prob. 10.4.1CPCh. 10.4 - Prob. 10.4.2CPCh. 10.4 - Prob. 10.4.3CPCh. 10.4 - Prob. 10.4.4CPCh. 10.7 - Prob. 10.7.1CPCh. 10.7 - Prob. 10.7.2CPCh. 10.7 - How do you convert an integer into a string? How...Ch. 10.7 - Show the output of the following code: public...
Ch. 10.7 - Prob. 10.7.5CPCh. 10.8 - What are autoboxing and autounboxing? Are the...Ch. 10.8 - Show the output of the following code. public...Ch. 10.9 - What is the output of the following code? public...Ch. 10.10 - Suppose s1, s2, s3, and s4 are four strings, given...Ch. 10.10 - To create the string Welcome to Java, you may use...Ch. 10.10 - What is the output of the following code? String...Ch. 10.10 - Let s1 be Welcome and s2 be welcome Write the...Ch. 10.10 - Prob. 10.10.5CPCh. 10.10 - Prob. 10.10.6CPCh. 10.10 - Prob. 10.10.7CPCh. 10.10 - Prob. 10.10.8CPCh. 10.10 - What is wrong in the following program? 1public...Ch. 10.10 - Show the output of the following code: public...Ch. 10.10 - Show the output of the following code: public...Ch. 10.11 - Prob. 10.11.1CPCh. 10.11 - Prob. 10.11.2CPCh. 10.11 - Prob. 10.11.3CPCh. 10.11 - Prob. 10.11.4CPCh. 10.11 - Prob. 10.11.5CPCh. 10.11 - Suppose s1 and s2 are given as fot tows:...Ch. 10.11 - Show the output of the following program: public...Ch. 10 - (The Time class) Design a class named Time. The...Ch. 10 - (The BMI class) Add the following new constructor...Ch. 10 - (The MyInteger class) Design a class named...Ch. 10 - Prob. 10.4PECh. 10 - (Display the prime factors) Write a program that...Ch. 10 - (Display the prime numbers) Write a program that...Ch. 10 - Prob. 10.7PECh. 10 - Prob. 10.8PECh. 10 - (The Course class) Revise the Course class as...Ch. 10 - Prob. 10.10PECh. 10 - Prob. 10.11PECh. 10 - (Geometry: the Triangle2D class) Define the...Ch. 10 - (Geometry: the MyRectangle 2D class) Define the...Ch. 10 - (The MyDate class) Design a class named MyDate....Ch. 10 - (Geometry: the bounding rectangle) A bounding...Ch. 10 - (Divisible by 2 or 3) Find the first 10 numbers...Ch. 10 - (Square numbers) Find the first 10 square numbers...Ch. 10 - (Mersenne prime)A prime number is called a...Ch. 10 - (Approximate e) Programming Exercise 5.26...Ch. 10 - (Divisible by 5 or 6) Find the first 10 numbers...Ch. 10 - (Implement the String class) The String class is...Ch. 10 - (Implement the String class) The String class is...Ch. 10 - (Implement the Character class) The Character...Ch. 10 - (New string split method) The split method in the...Ch. 10 - (Implement the StringBuilder class) The...Ch. 10 - (Implement the StringBuilder class) The...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- One interesting application of computers is drawing graphs and bar charts (sometimes called histograms). Write a script that reads five numbers between 1 and 30. For each number read, output HTML5 text that displays a line containing the same number of adjacent asterisks. For ex- ample, if your program reads the number 7, it should output HTML5 text that displays *******.arrow_forwardIn Java, please write a program that asks the user to enter a string, and then converts that string to Morse code. Use hyphens for dashes and periods for dots. Morse Code Table Character Code Character Code Character Code Character Code space space 6 - . . . . G --. Q --.- comma --..-- 7 -- . . . H . . . . R .-. period .-.-.- 8 ---.. I .. S . . . question mark ..--.. 9 ----. J .--- T - 0 ----- A .- K -.- U ..- 1 .---- B - . . . L .-.. V . . . - 2 ..--- C -.-. M -- W .-- 3 . . . -- D -.. N -. X -..- 4 . . . .- E . O --- Y -.-- 5 . . . .. F ..-. P .--. Z --..arrow_forward1. write a javascript program that prompts the user to enter the three integers and display the integers in non-decreasing oder. 2. write a javascript program that prompts the user to enter a three-digit integer and determine whether it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to right.arrow_forward
- An element has a number, name, symbol, and atomic mass(weight). For example, Oxygen isnumber 8 on the periodic table, its symbol is O, and its atomic mass is 15.999. Create a java class to represent an element. When printed to standard output, yourelement class should use a string formatted like the example below: Element{number=8, name='Oxygen', symbol='O', weight=15.999}arrow_forwardJava Write a program that allows a user to enter three words, and display the appropriate three-letter acronym in all uppercase letters. If the user enters more than three words, ignore the extra words.arrow_forwardJava Code Please Output The first few lines contain the drawn rectangle. After one empty line, the next line prints either "RECTANGLE" or "SQUARE". This is then followed by its area, perimeter, and the coordinates of its center point. #·#·#·#·#·# #·········# #·········# #·········# #·········# #·········# #·········# #·········# #·#·#·#·#·# RECTANGLE AREA:·40 PERIMETER:·26 CENTER·POINT:·(2.50,4.00)arrow_forward
- Write a java application for Limpopo’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the user enters an invalid item. ALSO SHOW OUTPUTarrow_forwardWrite a java application for Limpopo’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the user enters an invalid item. NB:ALSO SHOW OUTPUTarrow_forwardWrite an application that prints your initials in large block letters. Make each large letter out of the corresponding characters. Use escape sequences to form your initials. Make sure your initials are the same size as the example below. Programming language: JAVA Initial: SParrow_forward
- HELLO! PLEASE HELP ME FIX THE ERROR THANKYOU. :) JAVA CODE: class quad{public static void main(String args[] ){Quadrilateral quadrilateral = new Quadrilateral( 1.1, 1.2, 6.6, 2.8, 6.2, 9.9, 2.2, 7.4 );Trapezoid trapezoid = new Trapezoid (0.0, 0.0, 10.0, 0.0, 8.0, 5.0, 3.3, 5.0 );Parallelogram parallelogram = new Parallelogram (5.0, 5.0, 11.0, 5.0, 12.0, 20.0, 6.0, 20.0 );Rectagle rectagle = new Rectagle(17.0, 14.0, 30.0, 14.0, 30.0, 28.0, 17.0, 28.0 );Square square = new Square( 4.0, 0.0, 8.0, 0.0, 8.0, 4.0, 4.0, 4.0 );System.out.printf("%s %s %s %s %s\n", quadrilateral, trapezoid, parallelogram, rectagle, square );}}class Point{private double x;private double y;public Point(double xCoordinate, double yCoordinate){x = xCoordinate;y = yCoordinate;}public double getX(){return x;}public double getY(){return y;}public String toString(){return String.format( "( %.1f, %.1f)", getX(), getY() );}}class Quadrilateral {private Point point1;private Point point2;private Point point3;private…arrow_forwardPlease add a line(s) of code to the java code below. And comment the java code. Refer to image below and show output of the sierpenski triangle import java.awt.Color;import java.awt.Graphics;import javax.swing.JFrame; public class SierpinskiTriangle extends JFrame { public SierpinskiTriangle() { setTitle("Sierpinski Triangle"); setSize(1000,1000); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public void paint(Graphics g) { g.setColor(Color.BLUE); sierpinski(g, 500, 250, 500); } public void sierpinski(Graphics g, int x1, int y1, int side) { int x2 = x1 + side; int x3 = x1 + side / 2; int y2 = y1 - (int) (Math.sqrt(3.0) / 2.0 * side); int y3 = y1 + (int) (Math.sqrt(3.0) / 2.0 * side); if (side < 10) { g.drawLine(x1, y1, x2, y1); g.drawLine(x2, y1, x3, y2); g.drawLine(x3, y2, x1, y1); } else { sierpinski(g, x1, y1, side / 2);…arrow_forwardSuppose s1 and s2 are two strings. Which of the following statement or expression is valid in Java ? a - String s3 = s1 + s2; b - s1 >= s2; c - int i = s1.length; d - s1.charAt(0) = '5';arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Expressions in C++ | C++ tutorial for beginners; Author: Tutorial Mart;https://www.youtube.com/watch?v=XHbsZGpmRc8;License: Standard YouTube License, CC-BY
expression in python # python expressions; Author: Abhishek Tripathi;https://www.youtube.com/watch?v=Cc-kJGRjH6k;License: Standard Youtube License