Thread: Inheritance

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    10
    Rep Power
    0

    Inheritance


    Is this following code correct?

    Interface Car(...)
    Class M implements Car (...)
    Class F extends M (...)
    Car c1=new F();
    F m1=new M();
    Car c2=new M();


    c1 can be a F object?
    And m1 cannot be a M object, right?

    thank you!
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    What happens when you ask that question of the compiler by writing a short test program and compiling it?

IMN logo majestic logo threadwatch logo seochat tools logo