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% (1 review)
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...
-
An experiment was conducted to study the effect of temperature and type of oven on the life of a particular component being tested. Four types of ovens and 3 temperature levels were used in the...
-
The following cost data, which include operating cost and depreciation of capital investment, pertain to Exercise 9.1. Determine by finding the total cost for each of the 14 possible sequences: (a)...
-
Describe some of the ways the Internet has or has not impacted the way you (1) buy groceries, (2) make travel plans, (3) read news, (4) follow your favorite sports team, (5) decide which movie to see...
-
1. Two crates with treasure, a small one with mass m=110kg and a large one with mass M=329kg are connected by a massless rope and are on a frozen lake which you may assume to be frictionless. A rope...
-
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?
-
Why would you recommend project management software to someone involved in project management? What features and benefits does it provide?
-
What is the difference between a public and a private nuisance?
-
What strategies does business use to manage legal risk?
-
Why is gratitude not a sufficient consideration to bind a promisor?
-
Distinguish the civil law system from the common law system.
-
Explain the requirements necessary to successfully apply equitable estoppel.
-
What is context-sensitive help? Does your word processor have context-sensitive help?
-
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...
-
The customer sales activity includes activities such as order taking and refund processing. The cost of the assets and personnel to staff these activities is $91,560. With this level of staffing and...
-
Bake it Stop, a famous bakery known for its doughnuts, lease on a vehicle expired on January 1, 2023 and it returned the asset to the lessor at that time. Bake it Stop initially recorded an ROU asset...
-
Here is a table with information about some students: Name StudentID 123456 Joe Smith Abby Jones 234567 Credits GPA. 3.2 24 3.6 220 And a ToDo list transaction based on Joe earning an A in a 4 credit...
Study smarter with the SolutionInn App