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).When an object is created by a constructor of the class, the resulting object is called an instance of the class, and the member variables specific to the object are called instance variables, to contrast with the class variables shared across the class. In certain languages, classes are, as a matter of fact, only a compile time feature (new classes cannot be declared at run-time), while in other languages classes are first-class citizens, and are generally themselves objects (typically of type Class or similar). In these languages, a class that creates classes within itself is called a metaclass.

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
AbstractClassMustImplementAbstractMethodJava
An abstract class must implement all abstract methods defined in its superclass
Misconception
AbstractClassNoImplementationJava
An abstract class cannot contain implemented methods
Misconception
AddMemberAtRuntimeJava
Set of class members can change at runtime
Misconception
AllClassesHaveDefaultConstructorJava
All classes automatically get a no-argument constructor
Misconception
AnyClassExceptionJava
Any class can be an exception class
Misconception
ArrayListIsArrayJava
ArrayLists are arrays
Misconception
CallNotStaticallyCheckedJava
A method invocation on a reference of a type that does not have that method won't compile
Misconception
ClassDefinesTypeJavaScript
The type of an object is equivalent to the type defined by its class definition
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
ImmutableRequiresFinalParametersJava
Immutable classes need final constructor/method parameters
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
MethodAsFieldJava
Each object contains its own special fields for all of its methods
Misconception
MethodsWithoutClassJava
Methods can be defined outside a class
Misconception
MultipleSuperclassesJava
A class can have multiple superclasses
Misconception
NestedObjectsImplyNestedClassesJava
If objects are part of a containment hierarchy, their classes are nested, too
Misconception
NoFieldInheritanceJava
An object contains only the fields declared in its class
Misconception
NoMethodInheritanceJava
Subclasses inherit fields but not methods
Misconception
PrivateFieldsImplyImmutabilityJava
A class where all fields are private is immutable
Misconception
PrototypesAreClassesJavaScript
JavaScript is based on a class-based object model
Misconception
ReferringToRecursiveStructureMakesRecursiveJava
A class referring to a recursive data structure is (indirectly) part of that recursion as well
Misconception
SetterIsStaticJava
Setter methods are static
Misconception
SuperclassObjectAllocatedJava
When instantiating an object of a subclass, an object of a superclass is also allocated
Misconception
UnqualifiedNamesMustDifferJava
The unqualified names of different classes must be different
Misconception
UseOfSelfTypeImpliesRecursiveTypeJava
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.