Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java language 2. - Consider the class Car that implements Serializable. The Car class has three attributes plateNumber, make, and price. - Use the following

java language
image text in transcribed
2. - Consider the class Car that implements Serializable. The Car class has three attributes plateNumber, make, and price. - Use the following code of the CarTester class and accordingly write the required code in class CarRep. - Compile and run the code. You should have this output: import java.util, Arraylist; public class CarTester \{ public (arTester() \{ ArroylisteCar> cars = new Arraylist cars O; cars. odd(new Car("A123", "Toyota", 58600)); cars, add(new Car("B123", "Honda", 4009))); cars add(new. Cor("C123", "Nissan", 6e860)); cars. add(new Car("D123", "Ford", 38000)): Warite the objects of the list "theCars" to the file "carsfile" as objects. CarRepo, writetoabjFile("carsfile", cars); I/reod the cars objects fron the file cansfile" into the list "theCars" Arraylist clars theCors; the Cors = Carkepo, readframobjFile("carsfile"): for(Car c : thecars) f Systen, out,println(c, tostring O); 3 Zodify sone the secand car object by adding 2000 to the price. theCars.get(1) : setPrice(theCors.get(1), getPriceO+2eae); //write the data of the cars objects of the list "theCars" to a text file "carsfile.txt" Correpo, writefotextFile "carsffle. txt", theCars): / Reod the dota of the cars object from the text file "carsfile.txt" tinto the List theCarsz. ArroylisteCarn theCarsz - CarRepo. neadironiextfile'"carsfile, txt"): f/Add the car objects of the list "theCars?" to the list "thelars" for(Cor c : theCorsi) f thecars iada(c); 1 forisplay the contents of the list "theCors". for(Cor c : theCars) f 3. System, out.printlen(c.tostring(J); 1 public static vold nain(stringD args) if nen Cortestero

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions