June 2018
Beginner
722 pages
18h 47m
English
A class can acquire (inherit) all the non-private non-static members, so that when we use the object of this class, we cannot have any idea where these members actually reside – in this class or in the class from which they were inherited. To indicate inheritance, the keyword extends is used. For example, consider the following classes:
class A { private void m1(){...} public void m2(){...}}class B extends class A { public void m3(){...}}class C extends class B {}
In this example, the objects of classes B and C behave as if each of them has methods m2() and m3(). The only limitation is that a class can extend one class only. Class A is a base (or parent) class for both class B and class C. Class B is a base class for class C
Read now
Unlock full access