title: Achieve code reusability in inheritance in java
body: <p>I heard that code reusability we can achieve through inheritance, example: from a super class A, we can inherit the methods other than private methods to class B if it is extended and assume that both the classes are in same package. If this is the way to achieve code reusability in inheritance, then the same we can also get by creating an object of that class A right? I mean by creating an object we can access the public methods other than private methods right? why we need inheritance here? What is the code re usability in inheritance?</p>