inheritance
10 tutorials tagged “inheritance”.
- Serialization with Inheritance and Object ReferencesHow serialization treats superclasses that aren't Serializable, shared references, and cycles, so each object is written once and restored correctly.
- Composition vs InheritanceWhen to extend a class and when to hold one as a field: the is-a test, fragile base classes, a wrong extends refactored, and a checklist.
- The Diamond ProblemWhy Java has no multiple inheritance of classes: the diamond problem, clashing interface default methods, and resolving them explicitly.
- Constructor Calls in InheritanceHow constructors run in a hierarchy: the chain up to Object, the order bodies run in, the automatic super() call, and the no-arg error.
- Inheritance in JavaBuild a class on an existing one with extends: what a subclass inherits, adds or overrides, the is-a test, protected access, and Object.
- Method Overriding in JavaA subclass replaces an inherited method with its own version: how overriding works, @Override, reusing the parent with super, and a silent typo bug.
- Multiple Inheritance Through InterfacesA class can implement many interfaces and an interface can extend many: how Java gets multiple inheritance of type without the diamond problem.
- Java Super KeywordThe three uses of super: calling the parent's constructor, calling the parent's version of an overridden method, and reaching a hidden field.
- Types of InheritanceSingle, multilevel and hierarchical inheritance with examples, why multiple and hybrid inheritance of classes aren't allowed, and how interfaces fill that gap.
- Upcasting and DowncastingTreat a child object as its parent type and back again: what the reference type allows, ClassCastException, and instanceof patterns.