标签:
1.Private members of superclass are not directly accessible to subclass. As in this example, Animal variable noOfLegs is not accessible to Cat class but it can be indirectly accessible via getter and setter methods.
2.Superclass members with default access is accessible to subclass ONLY if they are in same package.
3.Superclass constructors are not inherited by subclass.
4.If superclass doesn’t have default constructor, then subclass also needs to have an explicit constructor defined. Else it will throw compile time exception.
5.Java doesn’t support multiple inheritance, a subclass can extends only one class. So here Animal is implicitly extending Object class and Cat is extending Animal class but due to java inheritance transitive nature, Cat class also extends Object class.
摘自:http://www.journaldev.com/644/inheritance-in-java-example
版权声明:本文为博主原创文章,未经博主允许不得转载。
Important Points for Inheritance in Java
标签:
原文地址:http://blog.csdn.net/leochang130731/article/details/46776243