How are encapsulation and abstraction implemented in Java or C++, and what is the practical difference between inheritance and an interface?