give a example of using tostring methods below is


Give a example of Using toString() Methods ?

Below is a version of CarTest in which uses toString() and System.out.println() instead of printing the fields in a straight line and thus works along with the new Car class which makes its fields private.

class CarTest5 {

public static void main(String args[]) {

Car c = new Car("New York A45 636", 123.45);
System.out.println(c);

for (int i = 0; i < 15; i++) {
c.accelerate(10.0);
System.out.println(c);
}

}

}

 

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: give a example of using tostring methods below is
Reference No:- TGS0284738

Expected delivery within 24 Hours