Advertisement
Kawsar_Hossain

Untitled

Feb 17th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public class Vehicle{
  2. public String model;
  3. public double weight;
  4. public Vehicle(String m,double w)
  5. {
  6. model=m;
  7. weight=w;
  8. }
  9. public void display()
  10. {
  11. System.out.println("Model:"+model);
  12. System.out.println("Weight:"+weight);
  13.  
  14. }
  15. }
  16.  
  17. public class Honda extends Vehicle{
  18.  
  19. private int noWheel;
  20. private double price;
  21. public Honda(int n,double p)
  22. {
  23. noWheel=n;
  24. price=p;
  25. }
  26. public static void main(String[] args) {
  27.  
  28. Vehicle ob1= new Vehicle("toto",6);
  29. Honda ob2 = new Honda(4,10.09);
  30. ob2.display();
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement