Inheritance

Inheritance is a way to define a class by reusing the definition of another class.

Related concepts:  ClassMemberSubtyping

Closest Wikipedia entry:  Inheritance (object-oriented programming) — In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation. Also defined as deriving new classes (sub classes) from existing ones such as super class or base class and then forming them into a hierarchy of classes. In most class-based object-oriented languages, an object created through inheritance, a "child object", acquires all the properties and behaviors of the "parent object" , with the exception of: constructors, destructor, overloaded operators and friend functions of the base class.

Misconceptions about Inheritance
16 documented Misconceptions

Check Yourself
Misconception
AbstractClassMustImplementAbstractMethod
An abstract class must implement all abstract methods defined in its superclass
Misconception
AbstractClassNoImplementation
An abstract class cannot contain implemented methods
Misconception
ConcreteClassMustOverride
A concrete class needs to implement all methods declared in its abstract superclasses
Misconception
ConcreteClassOnlyImplementClassAbstract
A concrete class only needs to implement those abstract methods it inherits from abstract superclasses
Misconception
ConcreteClassOnlyImplementDirectAbstract
A concrete class only needs to implement abstract methods declared in its direct supertypes
Misconception
ConcreteClassOnlyImplementInterfaceAbstract
A concrete class only needs to implement those abstract methods it inherits from interfaces
Misconception
ImplicitInterfaceImplementation
Java implicitly produces implementations of any methods a class inherits from the interfaces it implements
Misconception
InterfaceExtendClass
An interface can extend a class
Misconception
NoMethodInheritance
Subclasses inherit fields but not methods
Misconception
PrivateAccessibleInSubclass
Private members of a superclass are accessible from a subclass
Misconception
StaticDispatch
The method to be called is determined by the static type
Misconception
SubtypeCompatibleWithSupertype
A variable of a subtype can reference an object of a supertype
Misconception
SuperAlwaysHasParentheses
To call a method on a superclass, parentheses are needed after the keyword super
Misconception
SuperNotFirstStatement
super() can be called anywhere in the constructor of a subclass
Misconception
SuperclassObjectAllocated
When instantiating an object of a subclass, an object of a superclass is also allocated
Misconception
SupertypeIncompatibleWithSubtype
A variable of a supertype cannot reference an object of a subtype

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.