Encapsulation is a mechanism that binds together code and data it manipulates, and keeps both safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.Inheritance defines "is-a" hierarchy among classes in which one subclass inherits from one or more generalised super classes.