Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
705 B
0
Indexable
Never
public class Vehicle{
      int displacement = 0;
  
      public void setDisplacement(int d) {
         this.displacement = d;
      }
  
      public void getDisplacement() {
         System.out.println(this.displacement);
      }
}

public class Car{
  public Car(){
      Vehicle v = new Vehicle();
      v.setDisplacement(10);
  }
}

public class Bike{
   public Bike(){
      Vehicle v = new Vehicle();
      v.getDisplacement();
  }
}

public class MyClass {
    
    public static void main(String args[]) {
     
      MyClass m=new MyClass();
      m.test();
    }
    
    public  void test() {
      Car c = new Car();
      Bike b = new Bike();
    }
}
Leave a Comment