title: Having trouble running my code example of polymorphism in Java
body: <p>I copied a bicycle example and want to change it to a car example but I can't get the extended class Mountainbike of the class PolyCar to run.  If I comment out Mountainbike, PolyCar will run.  Can anyone tell me why the program does not recognize Mountainbike</p>
  
  <p>Here is the TestCar program used to run my PolyCar program</p>
  
  <pre><code>//import PolyCar.MountainBike;
  //import PolyCar.RoadBike;
  
  public class TestCars {
        public static void main(String[] args){
          PolyCar bike01, bike02, bike03;
  
          bike01 = new PolyCar(20, 10, 1);
          bike02 = new MountainBike(20, 10, 5, "Dual");
  //      bike03 = new RoadBike(40, 20, 8, 23);
  
          bike01.printDescription();
          bike02.printDescription();
  //      bike03.printDescription();
        }
      }
  </code></pre>
  
  <p>Here is my PolyCar Code</p>
  
  <pre><code>public class PolyCar {
  
      // the PolyCar class has three fields
      public int cadence;
      public int gear;
      public int speed;
  
      // the PolyCar class has one constructor
      public PolyCar(int startCadence, int startSpeed, int startGear) {
          gear = startGear;
          cadence = startCadence;
          speed = startSpeed;
      }
  
      // the PolyCar class has four methods
      public void setCadence(int newValue) {
          cadence = newValue;
      }
  
      public void setGear(int newValue) {
          gear = newValue;
      }
  
      public void applyBrake(int decrement) {
          speed -= decrement;
      }
  
      public void speedUp(int increment) {
          speed += increment;
      }
  public void printDescription(){
      System.out.println("\nBike is " + "in gear " + this.gear
          + " with a cadence of " + this.cadence +
          " and travelling at a speed of " + this.speed + ". ");
  }
  public class MountainBike extends PolyCar {
      private String suspension;
  
      public MountainBike(
                 int startCadence,
                 int startSpeed,
                 int startGear,
                 String suspensionType){
          super(startCadence,
                startSpeed,
                startGear);
          this.setSuspension(suspensionType);
      }
  
      public String getSuspension(){
        return this.suspension;
      }
  
      public void setSuspension(String suspensionType) {
          this.suspension = suspensionType;
      }
  
      public void printDescription() {
          super.printDescription();
          System.out.println("The " + "MountainBike has a" +
              getSuspension() + " suspension.");
      }
  } 
  public class RoadBike extends PolyCar{
      // In millimeters (mm)
      private int tireWidth;
  
      public RoadBike(int startCadence,
                      int startSpeed,
                      int startGear,
                      int newTireWidth){
          super(startCadence,
                startSpeed,
                startGear);
          this.setTireWidth(newTireWidth);
      }
  
      public int getTireWidth(){
        return this.tireWidth;
      }
  
      public void setTireWidth(int newTireWidth){
          this.tireWidth = newTireWidth;
      }
  
      public void printDescription(){
          super.printDescription();
          System.out.println("The RoadBike" + " has " + getTireWidth() +
              " MM tires.");
      }
  }
  
  }
  </code></pre>