Fri Feb 06, 2009 10:59 pm
package codemiles;
public class Car {
protected int CarSpeed;
protected String CarModel;
private int ID=0;
public void setCarModel(String CarModel) {
this.CarModel = CarModel;
}
public void setCarSpeed(int CarSpeed) {
this.CarSpeed = CarSpeed;
}
public String getCarModel() {
return CarModel;
}
public int getCarSpeed() {
return CarSpeed;
}
// Main Function
public static void main(String[] args) {
}
}
class RaceCar extends Car
{
public void RunTurbo()
{
CarSpeed+=100;
}
}
Any instance of of RaceCar can use the members of Car class except the variable (int ID) because it is private.
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.