Not every Person is a Father, and that's what inheritance represents. If class B inherits from class A, it means that every instance of class B has the abilities of class A, and anywhere that expects an A can be given a B instead.
This is probably easier to understand if we add a third class to the example: Mother. Intuitively, a Mother is a Person, but not a Father; and a Father is not a Mother either. So code that expects a Father and is given a Mother won't work; but code that expects a Person can be given a Father or a Mother. So, we would write "class Father extends Person", and "class Mother extends Person".
Not every Person is a Father, and that's what inheritance represents. If class B inherits from class A, it means that every instance of class B has the abilities of class A, and anywhere that expects an A can be given a B instead.
This is probably easier to understand if we add a third class to the example: Mother. Intuitively, a Mother is a Person, but not a Father; and a Father is not a Mother either. So code that expects a Father and is given a Mother won't work; but code that expects a Person can be given a Father or a Mother. So, we would write "class Father extends Person", and "class Mother extends Person".
Thanks man... I figured that out from your first response
I think this article has helped me more than it will help any reader and I made some changes which you can check out too
I'm grateful.