Question: Given the following class definition: public class Car { private double fuelLevel; public Car ( double gallons ) { fuelLevel = gallons; } public void

Given the following class definition:
public class Car
{
private double fuelLevel;
public Car(double gallons)
{
fuelLevel = gallons;
}
public void addGas(double gallons)
{
fuelIevel += gallons;
}
3
and this code segment:
Car car1= new Car(20);
Car car2= car1;
car2. addGas(10);
What is the value stored in fue LLevel for car 1?
30.0
20.0
0.0
10.5
 Given the following class definition: public class Car { private double

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!