Subtypes vs Inheritance ? Related or Different?

Viewed 75

Following a basic example in Java in my view, subtypes and inheritance are related.

 public class A extends B implements C{.....}

 public interface D {......}

 public interface C extends D {......}

 C c = new A(); // I thinks this is subtyping 
 B b= new A(); //  because A inherits B and can also referred as subtyping
 D d= new A(); // because D is a superinterface and it is also referred as subtyping

So, in what point actually "being subtype of" and "inherited from" is different? I am seeing that they are related and I think inheritance is a subset of Subtyping. But in many articles I notice that there have some differences between them. I didn't get any clear idea about though.

Edit:- That questions points out differences of overriding methods between private and protected cases. In my questions I emphasizes about Subtypes vs inheritance.

0 Answers
Related