Object Oriented Programming/Superclasses

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Superclasses are the parents of subclasses. [1] In relationships between two objects, a superclass is the name given to the class that passes down it's 'traits'(language entities.) [2] An example of a superclass would be an object like 'car' which would hold information like, make, model, mileage etc. An example of a Superclasses's format can be found below.

public class Person
{
}

Virtual methods[edit | edit source]

From the wikipedia page on inheritence: "If the superclass method is a virtual method, then invocations of the superclass method will be dynamically dispatched. Some languages require that methods be specifically declared as virtual (e.g. C++), and in others, all methods are virtual (e.g. Java). An invocation of a non-virtual method will always be statically dispatched (i.e. the address of the function call is determined at compile-time). Static dispatch is faster than dynamic dispatch and allows optimisations such as inline expansion."[3]


References[edit | edit source]