propellerads adcombo
Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

inheritance

Discussion in 'Programming and Scripts' started by gkumar, Sep 1, 2009.

  1. gkumar

    gkumar Affiliate affiliate

    65
    0
    0
    How does Java inheritance work?
     
  2. sdnsoft

    sdnsoft Affiliate affiliate

    14
    0
    0
    Like in all other object programming languages. If you have class A that have some public or protected attributes and you create class B that inherit from A then B by B you can access all public attributes of B and A as well and in B you can access protected attributes from A.

    Simple sample (because topic is much more complicated i would suggest reading some documentation or tutorials about object programing):

    class Vechicle
    {
    public String Engine; //all our vechicles have some kind of engine
    }

    class Bike inherit Vechicle
    {
    public bool IsCross;
    }

    Next you can use:
    Bike honda = new Bike();
    honda.IsCross=true;
    honda.Engine = "750";

    Hope it will help to start...
     

Featured Resources (View All)

adsxposed