Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Vehicle{
- public String model;
- public double weight;
- public Vehicle(String m,double w)
- {
- model=m;
- weight=w;
- }
- public void display()
- {
- System.out.println("Model:"+model);
- System.out.println("Weight:"+weight);
- }
- }
- public class Honda extends Vehicle{
- private int noWheel;
- private double price;
- public Honda(int n,double p)
- {
- noWheel=n;
- price=p;
- }
- public static void main(String[] args) {
- Vehicle ob1= new Vehicle("toto",6);
- Honda ob2 = new Honda(4,10.09);
- ob2.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement