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
Given the method definiton public void foo(List<Object>) { ... } What happens if you want to...
Given the method definiton public void foo(List<Object>) { ... } What happens if you want to call foo(new ArrayList<String>);
What is the output of this code sequence? String s = "A" + "BC" + "DEF"...
What is the output of this code sequence? String s = "A" + "BC" + "DEF" + "GHIJ"; System.out.println( s ); 1) A BC DEF GHIJ 2) ABCDEFGHIJ 3)s 4)abcdefghij
//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...