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 like C++, an object created through inheritance, a "child object", acquires all the properties and behaviors of the "parent object", with the exception of: constructors, destructors, overloaded operators and friend functions of the base class.

Misconceptions about Inheritance
16 documented Misconceptions

Check Yourself
Misconception
AbstractClassMustImplementAbstractMethodJava
An abstract class must implement all abstract methods defined in its superclass
Misconception
AbstractClassNoImplementationJava
An abstract class cannot contain implemented methods
Misconception
ConcreteClassMustOverrideJava
A concrete class needs to implement all methods declared in its abstract superclasses
Misconception
ConcreteClassOnlyImplementClassAbstractJava
A concrete class only needs to implement those abstract methods it inherits from abstract superclasses
Misconception
ConcreteClassOnlyImplementDirectAbstractJava
A concrete class only needs to implement abstract methods declared in its direct supertypes
Misconception
ConcreteClassOnlyImplementInterfaceAbstractJava
A concrete class only needs to implement those abstract methods it inherits from interfaces
Misconception
ImplicitInterfaceImplementationJava
Java implicitly produces implementations of any methods a class inherits from the interfaces it implements
Misconception
InterfaceExtendClassJava
An interface can extend a class
Misconception
NoMethodInheritanceJava
Subclasses inherit fields but not methods
Misconception
PrivateAccessibleInSubclassJava
Private members of a superclass are accessible from a subclass
Misconception
StaticDispatchJava
The method to be called is determined by the static type
Misconception
SubtypeCompatibleWithSupertypeJava
A variable of a subtype can reference an object of a supertype
Misconception
SuperAlwaysHasParenthesesJava
To call a method on a superclass, parentheses are needed after the keyword super
Misconception
SuperNotFirstStatementJava
super() can be called anywhere in the constructor of a subclass
Misconception
SuperclassObjectAllocatedJava
When instantiating an object of a subclass, an object of a superclass is also allocated
Misconception
SupertypeIncompatibleWithSubtypeJava
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.