Whats wrong with replacing the println statement in Figure 14.2s main method with these two statements? String
Question:
What’s wrong with replacing the println statement in Figure 14.2’s main method with these two statements?
String description = car.toString();
System.out.println(description);
Figure 14.2
Transcribed Image Text:
/*************** ********* * Car2.java *Dean & Dean * * This instantiates a car and displays its properties. **** public class Car2 { private String make; // car's make private int year; private String color; // car's color //********** this.make = make; this.year = year: this.color = color; } // end Car2 constructor //*********** public Car2 (String make, int year, String color) ( @Override *********************** public String toString() ( // car's listed year } // end toString. //********** return "make = "+make+", year = ", color="+ color; } // end main } // end class Car2 ******/ public static void main(String[] args) ( ********** ********************** + year + ************** Car2 car= new Car2("Honda", "2020", "silver"); System.out.println(car); This overrides the Object class's toString method.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (4 reviews)
Nothing Its just a ...View the full answer
Answered By
Utsab mitra
I have the expertise to deliver these subjects to college and higher-level students. The services would involve only solving assignments, homework help, and others.
I have experience in delivering these subjects for the last 6 years on a freelancing basis in different companies around the globe. I am CMA certified and CGMA UK. I have professional experience of 18 years in the industry involved in the manufacturing company and IT implementation experience of over 12 years.
I have delivered this help to students effortlessly, which is essential to give the students a good grade in their studies.
3.50+
2+ Reviews
10+ Question Solved
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted:
Students also viewed these Computer science questions
-
The Cosmic Superclass Every Java class youve ever written isautomatically a subclass of java.lang.Object. This means thatpublic methods from Object are inherited by your classes, and youmay override...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Given the following information, prepare a production report with materials added at the beginning and ending work in process inventory being 20% complete with regard to conversion costs. Costs to...
-
In timestamp ordering, W-timestamp (Q) denotes the largest timestamp of any transaction that executed write (Q) successfully. Suppose that, instead, we defined it to be the timestamp of the most...
-
Usonic, Inc., has collected the following information on its cost of electricity: Required a. Prepare a scattergraph of Usonic's electricity costs for the year. Plot the total electricity cost on the...
-
Can you see why this condition is necessary?
-
Even though firms follow the accounting rules (GAAP) when presenting their financial statements it is still possible for conflicts of interest to exist between what management wants investors and...
-
a. 850000 h. $3560001 d. (630,000)
-
The return type of an overriding method must be the same as the return type of the overridden method. (T / F)
-
What is returned by the Object classs toString method?
-
Locate the centroid of the plane area shown. 10 in. 9 in. 12 in. S in.
-
Jennifer purchased stock at $50 per share with a 75% initial margin requirement and a maintenance margin of 35%. How much equity per share must Jennifer contribute when the stock falls to $15 per...
-
Thinking about your present job and your "inventory"of leadership traits and characteristics, where are your strengths and weaknesses as a leader?Is being a leader desirable? If yes, what motivates...
-
You are facing a complex decision with several courses of possible action and probabilities associated with them. The current decision tree, based on the best possible estimates of probabilities and...
-
1. In what ways has Marriot proven an industry leader in the context of entrepreneurship in the hospitality industry. 2. What are the author's metrics of measuring entrepreneurial activity, and do...
-
Suppose you want to model the relationship between the interest rate, the economic growth rate and the inflation rate. what would be first model to fit explain.
-
A point is moving on the graph of x3+ y2= 1 in such a way that its y coordinate is always increasing at a rate of 2 units per second. At which point(s) is the x coordinate increasing at a rate of 1...
-
With your classmates, form small teams of skunkworks. Your task is to identify an innovation that you think would benefit your school, college, or university, and to outline an action plan for...
-
Winger, Inc. is in the business of renting medical equipment for home health care. New government standards for lifts for disabled patients have rendered some equipment obsolete. Winger owns 10...
-
Use the impedance method to obtain the transfer function Vo(s)/Vs(s) for the circuit shown in Figure. Ri R2
-
Consider the following two mutually exclusive alternatives: Alternative B may be replaced with an identical item every 20 years at the same $150 cost and will have the same $24 uniform annual...
-
Pottery Ranch Inc. has been manufacturing its own finials for its curtain rods. The company is currently operating at 100% of capacity, and variable manufacturing overhead is charged to production at...
-
3. How much life insurance do you need? Calculating resources - Part 2 Aa Aa E Paolo and Maria Rossi have completed Step 1 of their needs analysis worksheet and determined that they need $2,323,000...
-
On March 1, LGE asks to extend its past-due $1,200 account payable to Tyson, Tyson agrees to accept $200 cash and a 180-day, 8%, $1,000 note payable to replace the account payable. (Use 360 days a...
Study smarter with the SolutionInn App