Concept explainers
(Implement the StringBuilder class) The StringBuilder class is provided in the Java library. Provide your own implementation for the following methods (name the new class MyStringBuilder1):
public MyStringBuilder1(String s);
public MyStringBuilder1 append(MyStringBuilder1 s);
public MyStringBuilder1 append(int i);
public int length( );
public char charAt(int index);
public MyStringBuilder1 toLowerCase();
public MyStringBuilder1 substring(int begin, int end);
public String toString();
Trending nowThis is a popular solution!
Chapter 10 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (9th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java How To Program (Early Objects)
Starting Out with Java: Early Objects (6th Edition)
Starting Out With Visual Basic (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- java program Add a divide method to the following program to take another Fraction as the parameter and return a new Fraction that is the division of current Fraction and the Fraction in the parameter. (public Fraction divide(Fraction f)). - Add scaleup and scaledown methods to the Fraction class. The scaleup method will take a factor as the parameter and multiply the numerator by the factor. The scaledown method will take a factor as the parameter and multiply the denominator by the factor. - Add a scale method that will have two parameters: factor and flag. The flag is boolean. If flag is true, then scale up the fraction; otherwise scale down the fraction. - Both scaledown and scale methods must check if the factor is 0. If it is 0, a warning message is printed out and no scaling is operated. - Add two more constructors. One of the constructors will have no parameters; it initializes the fraction to 0/1. The other constructor will have one parameter, representing the numerator of the…arrow_forwardFinish the TestPlane class that contains a main method that instantiates at least two Planes. Add instructions to instantiate your favorite plane and invoke each of the methods with a variety of parameter values to test each option within each method. To be able to test the functionality of each phase, you will add instructions to the main method in each phase.arrow_forwardMethod Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. Argument lists could differ in: 1. Number of parameters. 2. Data type of parameters. 3. Sequence of Data type of parameters. Write different version of method sum() that display the sum of the values received as parameter according to the following main method content: public static void main(String[] args) { sum ( 10, 10 ); sum ( 10, 10, 10 ); sum ( 10.0, 10.0 ); sum ( 10, 10.0 ); sum ( 10.0, 10); } You have to define five functions with the specified types. Then, demonstrate the Argument Promotion concept by reducing the number of method to two.arrow_forward
- (Implement MyLinkedList) The implementations of the methods contains(E e), get(int index), indexOf(E e), lastIndexOf(E e), and set(int index, E e) are omitted in the MyLinkedList class. Implement these methods. Define a new class named MyLinkedListExtra that extends MyLinkedListto override these methods. Test your new MyList class using the code at import java.util.*; public class Exercise24_02 { public static void main(String[] args) { new Exercise24_02(); } public Exercise24_02() { String[] names = {"Tom", "Susan", "Kim", "George", "Peter", "Jean", "George", "Jane", "Denise", "Jenny", "Susan", "Kathy", "Jane"}; MyList<String> list = new MyLinkedListExtra<>(names); System.out.println(list); Scanner input = new Scanner(System.in); System.out.print("Enter a name: "); String name = input.next(); System.out.print("Enter an index: "); int index = input.nextInt(); System.out.println(name + " is in the list? " +…arrow_forwardI just want this today is mY paper so Please Solve this.arrow_forwardCode with comments and output screenshot. Thank you!! Write a java method that receives a string containing letters of the English alphabet and then prints the Letters having unique frequencies. Notes: 1) Ignore letter case; Uppercase and lowercase letters are considered the same. 2) Do not use methods from the Arrays class.arrow_forward
- Problem 2: Complete the seperateDuplicateChars () method in Seperate Duplicates.java as follows: The method takes a String str as a parameter and returns a new String. The returned String should be exactly like str, but any identical characters that appear in a consecutive way must be separated by hyphens "-". You may ONLY use the following methods from the String class: charAt(), substring() and length(). Other than uncommenting the code, do not modify the main method in Seperate Duplicates.java. Sample runs provided below. Argument String str "Hello" "Bookkeeper" "Yellowwood door" "Chicago Cubs" Return String "Hel-lo" "Bo-ok-ke-eper" "Yel-low-wo-od do-or" "Chicago Cubs"arrow_forwardUse Java.arrow_forwardThe following class definition has errors. Explain what is wrong and why. Rewrite a correct version of the class. class Question2( public static main(String[] args){ int num1 = 10, num2 = 20, num3; (num2 / 2)--; num3 = (num1 + num2)/num3 System.out.printin( num3 );arrow_forward
- Find the errors in the following program .6 public class WelcomeClass } (public static void main(String[] args ;int student num = 11 ;(System.out.printIn("Welcom to our java class (System.out.println("The number of students in the class is:" student_num { } (سؤال غير مجهول ) * (2 نقطة) .There is a total of 5 errors, you need to find 4 of them You can upload a file to show your answer 1 تحميل ملف أقصى حد مسموح به لعدد الملفات: 1 أقصى حد مسموح به لحجم الملف الواحد: 10MB أنواع الملفات المسموح بها: PDF, صورة إرسالarrow_forwardwrite this java codearrow_forwardJava Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 3. Given the following code, the output is __. class Base { private int x = 5; }class Derived extends Base { x = 6; }public class Sample { public static void main(String[] args) { int x = 7; Derived d1 = new Derived(); System.out.print(d1.x); }} A. 0B. 5C. 6D. 7E. Error message Part 2 - 4. A class Animal has a subclass Mammal. Which of the following is true? A. class Animal extends Mammal { }B. class Mammal extends Animal { }C. class Animal implements Mammal { }D. class Mammal implements Animal { }E. class Mammal { Animal a1 = new Animal(); }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education