Class

A class is a blueprint for objects and defines a type with fields and methods.

Related concepts:  ObjectFieldMethodMemberTypePrototype

Closest Wikipedia entry:  Class (computer programming) — In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). In many languages, the class name is used as the name for the class (the template itself), the name for the default constructor of the class (a subroutine that creates objects), and as the type of objects generated by instantiating the class; these distinct concepts are easily conflated. Although, to the point of conflation, one could argue that is a feature inherent in a language because of its polymorphic nature and why these languages are so powerful, dynamic and adaptable for use compared to languages without polymorphism present.

Authoritative Definition

Wikipedia does not necessarily offer the best fitting definition of a concept. The exact meaning we attribute to the concept of Class is based on principled authoritative sources such as:

Misconceptions about Class
28 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
AddMemberAtRuntime
Set of class members can change at runtime
Misconception
AllClassesHaveDefaultConstructor
All classes automatically get a no-argument constructor
Misconception
AnyClassException
Any class can be an exception class
Misconception
ArrayListIsArray
ArrayLists are arrays
Misconception
CallNotStaticallyChecked
One can invoke a method on a reference of a class that does not have that method
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
ImmutableRequiresFinalParameters
Immutable classes need final constructor/method parameters
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
MethodAsField
Each object contains its own special fields for all of its methods
Misconception
MethodsWithoutClass
Methods can be defined outside a class
Misconception
MultipleSuperclasses
A class can have multiple superclasses
Misconception
NestedObjectsImplyNestedClasses
If objects are part of a containment hierarchy, their classes are nested, too
Misconception
NoFieldInheritance
An object contains only the fields declared in its class
Misconception
NoMethodInheritance
Subclasses inherit fields but not methods
Misconception
PrivateFieldsImplyImmutability
A class where all fields are private is immutable
Misconception
ReferringToRecursiveStructureMakesRecursive
A class referring to a recursive data structure is (indirectly) part of that recursion as well
Misconception
SetterIsStatic
Setter methods are static
Misconception
SuperclassObjectAllocated
When instantiating an object of a subclass, an object of a superclass is also allocated
Misconception
UnqualifiedNamesMustDiffer
The unqualified names of different classes must be different
Misconception
UseOfSelfTypeImpliesRecursiveType
If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.