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: 100% (QA)
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...
-
Troy Engines, Ltd., manufactures a variety of engines for use in heavy equipment. The company has always produced all of the necessary parts for its engines, including all of the carburetors. An...
-
1. To develop an understanding of your ethical leadership style 2. To understand how your preferred ethical leadership style relates to other ethical leadership styles Directions 1. Please read the...
-
STATED VALUE, COMMON AND PREFERRED STOCK, AND NONCASH ASSETS Kris Kraft Stores had the following stock transactions during the year: (a) Issued 4,000 shares of no-par common stock with a stated value...
-
A fleet of vehicles is comprised of 60 vans, 20 limos, and X sedans. If 10% of all vehicles are limos, how many sedans are in the fleet?
-
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?
-
Is a company really breaking even if it produces and sells at the break-even point? What costs may not be covered?
-
Consider a risky investment that depends on the weather. The investment is for one year, initial investment paid today and then a net cash inflow is realized in one year. Initial Investment $50...
-
3. Here is the declaration of a linked list node and head pointer. struct Node }; Node nextPtr_; int value_; Node headPtr; Write the code for the following function that searches the list for a node...
-
In 1995, Able purchased a parcel of real property described as "Lot 1 in Block 'A' in the City of Grover." In November 1996, Able conveyed a portion of Lot 1 to Baker by deed, which provided that he...
-
We often see the news report where hackers/scammers proliferate various company's' servers and gain personal data of customers. And we all have seen these class actions with these companies. Just...
-
Question 1 An investor, a writer, an actor, a professional athlete, and a food critic formed a general partnership to own and operate a high-end bistro. Each partner made a capital contribution. The...
-
The comparative balance sheet of Gold Medal Sporting Goods Inc. for December 31, 2008 and 2007 is shown as follows: The following additional information was taken from the records: a. The investments...
-
San Carlos Bank and Trust Company uses a credit-scoring system to evaluate most consumer loans that amount to more than $2,500. The key factors used in its scoring system are found at the conclusion...
-
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...
-
You are the owner of the local record store, and you are considering opening a coffee shop in a vacant area in the back of the store. You estimate that it will cost you $50,000 to set up the store...
-
JJ is planning for the future and wants to save $50, 000 for a down payment on a house. He currently has $10, 000 to invest, and the town bank offers 3% interest on all accounts. How long would it...
-
Pharoah Corporation sells three different models of a mosquito "zapper." Model A12 sells for $56 and has unit variable costs of $39.20. Model B22 sells for $112 and has unit variable costs of $78.40....
Study smarter with the SolutionInn App