Question

Given the StringBuilder object builder=“We Are”, what is the output of builder.append(“Family”)? Given the String object...

Given the StringBuilder object builder=“We Are”, what is the output of builder.append(“Family”)?

Given the String object value=“Online Education”, what is the output of value.substring(0,8)?

Homework Answers

Answer #1

class StringBuilderDrive {
   public static void main(String[] args) {
       // builder is mutable
       StringBuilder builder = new StringBuilder("We Are");

       // String is immutable
       String value = "Online Education";

       // printing builder
       System.out.println("builder Is\t\t\t: "+builder);

       // this will append "Family" at the end of builder
       builder.append("Family");

       // printing new builder
       System.out.println("builder.append(\"Family\") Is\t: "+ builder);
      
       //printing value
       System.out.println("\nvalue Is\t\t: "+value);

       // get required substring
       value = value.substring(0,8);

       System.out.println("value.substring(0,8) Is\t: "+value);
   }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A real estate builder wishes to determine how house size (House) is influenced by family income...
A real estate builder wishes to determine how house size (House) is influenced by family income (Income), family size (Size), and education of the head of household (School). House size is measured in hundreds of square feet, income is measured in thousands of dollars, and education is in years. The builder randomly selected 50 families and ran the multiple regression. The business literature involving human capital shows that education influences an individual’s annual income. Combined, these may influence family size....
A real estate builder wishes to determine how house size (House) is influenced by family income...
A real estate builder wishes to determine how house size (House) is influenced by family income (Income), family size (Size), and education of the head of household (School). House size is measured in hundreds of square feet, income is measured in thousands of dollars, and education is in years. The builder randomly selected 50 families and ran the multiple regression. Microsoft Excel output is provided below: SUMMARY OUTPUT             Regression Statistics Multiple R                         0.865 R Square                           0.748 Adjusted R Square            0.726 Standard Error                  5.195 Observations                     50...
Suppose that a small family farm sold its output for $100,000 in a given year. The...
Suppose that a small family farm sold its output for $100,000 in a given year. The family spent $25,000 on fuel, $40,000 on seed, fertilizer, and pesticides, and $25,000 on equipment, including maintenance. The family members could have earned $20,000 working at other occupations. What is the family’s accounting cost? What is the family’s economic cost? Could the family’s economic cost ever exceed its accounting cost? Why or why not?
Suppose that a small family farm sold its output for $100,000 in a given year. The...
Suppose that a small family farm sold its output for $100,000 in a given year. The family spent $25,000 on fuel, $40,000 on seed, fertilizer, and pesticides, and $25,000 on equipment, including maintenance. The family members could have earned $20,000 working at other occupations. What is the family’s accounting cost? What is the family’s economic cost? Could the family’s economic cost ever exceed its accounting cost? Why or why not two paragraphs or more
What is the output of the following Java program? class Food { String flavor = "bland";...
What is the output of the following Java program? class Food { String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; Pepper(String flavor) { this.flavor = flavor; } } public class Lunch { public static void main(String[] args) { Pepper pepper = new Pepper("sweet"); System.out.println(pepper.flavor); } } Select one: a. bland b. the program does not compile c. no output d. spicy e. sweet
//What is the output? import java.util.HashMap; public class AirportCodes {    public static void main (String[]...
//What is the output? import java.util.HashMap; public class AirportCodes {    public static void main (String[] args) {       HashMap<String, String> airportCode = new HashMap<String, String>();       airportCode.put("GRX", "Granada, Spain");       airportCode.put("ALB", "Albany, USA");       airportCode.put("IWJ", "Iwami, Japan");       System.out.print("ALB: ");       System.out.println(airportCode.get("ALB"));       airportCode.put("IWJ", "Ivalo, Finland");       System.out.print("IWJ: ");       System.out.println(airportCode.get("IWJ"));    } }
C++ 5a)We have the following class: class Banana { private:      string s;      int y;...
C++ 5a)We have the following class: class Banana { private:      string s;      int y; public: bool theMemberFunc (string); void setterForS(string); // setter for s string getterForS(); // getter for s }; Instantiate a static object of Banana named co. a)int Banana; b)co.Banana = new; c)Banana = new class; d)Banana co; 5b)Code a call to function aNonclassFunction passing co. a)aNonclassFunction (co); b)aNonclassFunction (* co); c)aNonclassFunction (aGoodClass.co); d)aNonclassFunction (aGoodClass); 5c)Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has...
What output do we get? How do we get that output? Consider the following method :...
What output do we get? How do we get that output? Consider the following method : public static void processArray (int [] array) { int x = 0; for (int i = 0; i < array.length - 1; i++ ) { if (array [i] < array [i+1]) { System.out.println (i + 1) ;         }     } } In the left-hand column below are specific arrays of integers. Indicate in the right- hand column what value would be printed by...
An object is undergoing rotational motion. We pick some point on the object that is a...
An object is undergoing rotational motion. We pick some point on the object that is a distance r from the axis of rotation. (a) Is it ever possible for aC = aT (at our selected point)? (b) If yes, then what value would the angular velocity, ω, have in terms of the angular acceleration, α? If no, why not? (c) Is it possible, at the point we have selected, to have a system undergo angular acceleration for some time period...
int a =12; a += 3; System.out.println(a); // What is the output of the above program?-----...
int a =12; a += 3; System.out.println(a); // What is the output of the above program?----- --------------- the Java keyword "new" accomplishes what? starts a new program gets input creates an object in memory refresh variable values ------------------------ Every Java Class MUST contain the main method: 'public static void main(String[]args)'   true/false
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT