Of course, the data in the "message" to the constructor will usually be stored in the instance variables, where it will remain until the object is destroyed (or until the instance variables are deliberately changed.)
Here is an interesting program. Is anything wrong?
import java.io.* ;
class Car
{
// instance variables
int startMiles; // Stating odometer reading
int endMiles; // Ending odometer reading
double gallons; // Gallons of gas used between the readings
// constructor
Car( int first, int last, double gals )
{
startMiles = first ;
endMiles = last ;
gallons = gals ;
}
// methods
double calculateMPG()
{
return (last - first)/gals ;
}
}
class MilesPerGallon
{
public static void main( String[] args )
{
Car car = new Car( 32456, 32810, 10.6 );
System.out.println( "Miles per gallon is " + car.calculateMPG() );
}
}