Misconceptions

Here are a couple of misconceptions. Many more to come...

Misconception Count Does Not Imply Language Difficulty

The is no connection between the number of misconceptions listed here and the difficulty of the corresponding programming language. The effort we spent on collecting misconceptions is very different for different languages. It would be inappropriate to reason about the quality of languages based on the number of misconceptions in this collection.

Java
DRAFT
AbstractClassMustImplementAbstractMethod
An abstract class must implement all abstract methods defined in its superclass
Java
DRAFT
AbstractClassNoImplementation
An abstract class cannot contain implemented methods
Java
AddMemberAtRuntime
Set of class members can change at runtime
AllClassesHaveDefaultConstructor
All classes automatically get a no-argument constructor
AnyClassException
Any class can be an exception class
Java
ArithmeticPlusPrecedes
Addition has higher precedence than string concatenation
Java
DRAFT
ArrayAccessWithParentheses
Parenthesis are used to access an element in an array
ArrayAllocationWithoutNew
Arrays are created without the new keyword
ArrayBracketCountIsLength
The number of brackets in an array type or an array initializer corresponds to the length of the array
ArrayElementTypeRepeats
The type of a multi-dimensional array is written as T[] T[] T[]
Java
DRAFT
ArrayElementsUntyped
Elements of arrays are untyped
Java
ArrayHasLengthMethod
To get the length of an array, one needs to call its length method
ArrayInitializerContentsInBrackets
Array initializers list the elements in square brackets
Java
DRAFT
ArrayLengthCannotBeZero
An array cannot have a length of 0 elements
ArrayLengthPartOfType
The length of an array is part of its type
Java
ArrayListIsArray
ArrayLists are arrays
ArrayRankIsLength
Array rank and array length are the same thing
ArrayRankNotPartOfType
The rank of an array is not part of its type
Java
ArraysGrow
Arrays can grow dynamically
Java
AssignCompares
= compares two values
Java
AssignmentCopiesObject
Assignment copies the object
Java
AssignmentNotExpression
An assignment a=b is not an expression
Java
DRAFT
BaseCaseNotNeeded
Recursive computations do not necessarily need a base case
BaseCaseSelfRecursive
The base case of a structural recursion consists of a recursive self-call
BoxedNull
Passing null to a wrapper class constructor creates an object representing the absence of a value
Java
CallNotStaticallyChecked
A method invocation on a reference of a type that does not have that method won't compile
CallOnPrimitive
One can invoke a method on primitive values
CallRequiresVariable
One needs a variable to invoke a method
CallWithoutFrame
A method invocation does not necessarily allocate a stack frame
CallerFrameContainsCalleeFormal
Stack frame of caller includes variables for callee's formal parameters
Java
CannotChainMemberAccesses
Member accesses cannot be chained together
Java
CannotChainMemberToConstructor
Method calls or field accesses cannot be chained to a constructor invocation
CatchAlwaysExecutes
Catch blocks always get executed
CatchProvidesOptions
Only the necessary part of a catch block executes
Java
DRAFT
ChainedMethodsNotCalledFromOutside
Chained methods are all called on the object at the beginning of the chain
Java
CharNotNumeric
Char is not a numeric type
Java
ComparisonWithBooleanLiteral
To test whether an expression is true or false, one must compare it to true or to false
CompositeExpressionsUntyped
Expressions that consist of multiple parts have no type
ConcreteClassMustOverride
A concrete class needs to implement all methods declared in its abstract superclasses
ConcreteClassOnlyImplementClassAbstract
A concrete class only needs to implement those abstract methods it inherits from abstract superclasses
ConcreteClassOnlyImplementDirectAbstract
A concrete class only needs to implement abstract methods declared in its direct supertypes
ConcreteClassOnlyImplementInterfaceAbstract
A concrete class only needs to implement those abstract methods it inherits from interfaces
ConditionOneOutEdge
A condition node in a control-flow graph can have a single outgoing edge
Java
ConditionalIsSequence
If-else is equivalent to sequence of two ifs
Java
ConstructorAllocates
The constructor allocates the object
ConstructorParameterIsField
Formal constructor parameters are equivalent to instance variables
Java
ConstructorReturnsObject
Constructors need to return objects
ConstructorWithoutNew
One can write the constructor name, without new, to instantiate a class
Java
ControlledLocalAccess
One can control access to local variables using access modifiers
Java
DeferredReturn
A return statement in the middle of a method doesn't return immediately
ElsIf
There is an elsif keyword for multi-way conditional statements
Java
DRAFT
ElseAlwaysExecutes
The else branch of an if-else statement always executes
Java
EqualityOperatorComparesObjectsValues
o==p compares the objects referred to by variables o and p
Java
EqualsComparesReferences
o.equals(p) compares the references stored in the variables o and p
EvaluationResultsArePrinted
Evaluating an expression means outputting its result
ExceptionRoot
Exception is the top-most exception class
Java
DRAFT
ExpressionAssigns
An expression that reads a variable also updates its value after the evaluation
ExpressionsDynamicallyTyped
One has to evaluate an expression to determine its type
Java
FinalReferenceImpliesImmutability
An object referred to by a final variable is an immutable object
Java
DRAFT
ForEachIteratesOverIndices
An enhanced for loop iterates over the indices of an array or a collection
ForEachTraversesRecursiveStructure
For-each loops know how to traverse any recursive data structure
ForEachVariableIsElement
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
ForIsConditional
The body of a for statement executes at most once
ForVariableScopeBeyondLoop
The scope of variables declared in a for loop header extends beyond the loop
FrameIsClassInstance
A stack frame is the same as an instance of a class
Java
IfIsLoop
The body of an if statement executes repeatedly, as long as the condition holds
IfRequiresElse
Every if statement requires an else
ImmutableRequiresFinalParameters
Immutable classes need final constructor/method parameters
ImplicitInterfaceImplementation
Java implicitly produces implementations of any methods a class inherits from the interfaces it implements
InlineCallInExpressionTree
The expression tree of an expression involving a call inlines the call's computation of the returned value
InlineVariableInExpressionTree
The expression tree of an expression involving a variable inlines the variable's definition
IntegerDivisionToRational
Dividing two integers can produce a rational number
InterfaceExtendClass
An interface can extend a class
InterproceduralEdge
In an intra-procedural control-flow graph, method call nodes point to the called method
Java
LargeIntegerLong
Large integer numbers have type long
LiteralNoExpression
A literal is not an expression
LiteralString
When passing a literal string as argument to a method, no quotes are needed
Java
LocalVariablesAutoInitialized
Local variables are automatically initialized
LoopBodyScopeImpliesLoopLifetime
Lifetime of variables declared in a loop body extends across all loop iterations
Java
DRAFT
LoopTerminatingCondition
For and while loops end when the condition becomes true
MapIsMultiMap
Maps can store multiple values for a given key
MapPutNoOverwrite
Map.put with an existing key does nothing
Java
MapToBooleanWithConditionalOperator
To map a boolean expression to a boolean, a conditional operator is necessary
Java
MapToBooleanWithIf
To map a boolean expression to a boolean, an if statement is necessary
MethodAsField
Each object contains its own special fields for all of its methods
MethodWithoutReturnType
A method declaration does not need to include a return type
MethodsWithoutClass
Methods can be defined outside a class
MultiReferenceVariable
A reference variable can point to multiple objects
MultiValueVariable
A variable can contain more than one value
MultidimensionalArray
A multi-dimensional array is one thing
MultipleSuperclasses
A class can have multiple superclasses
Java
MustInitializeFieldInConstructor
Constructors must assign values to all fields
NamedTypeParameter
To instantiate a generic type, one needs to specify type parameter names as well as types
NestedObjectsImplyNestedClasses
If objects are part of a containment hierarchy, their classes are nested, too
NestedPackages
Packages can contain other packages
Java
NoAtomicExpression
Expressions must consist of more than one piece
NoCallOnStringLiteral
One cannot invoke methods on String literals
NoCastIfSameSize
If a variable is at least as big (bit-width) as a value, then no cast is needed to a assign the value to the variable
NoCharEscape
\ is a normal character in char and String literals
Java
NoEmptyConstructor
A constructor must do something
NoFieldInheritance
An object contains only the fields declared in its class
NoFieldlessObjects
Objects without instance variables can't exist
Java
NoFloatLiterals
There are no float literals
Java
DRAFT
NoImplicitWidening
Smaller types are never automatically converted into bigger ones without an explicit cast
Java
DRAFT
NoInsideMethodCallInConstructor
It is foirbidden to call other methods on the same object while inside its constructor
NoJaggedArrays
Multi-dimensional arrays have a rectangular shape
NoLocalVariables
There are no local variables
Java
NoLongLiterals
There are no long literals
Java
DRAFT
NoMethodInheritance
Subclasses inherit fields but not methods
Java
NoReservedWords
Every sequence of letters and digits starting with a letter can be used as an identifier
Java
NoShortCircuit
&& and || always evaluate both operands
Java
NoSingleLogicAnd
& is only a bitwise AND
NoStringToString
One cannot invoke toString() on a String
Java
NullIsObject
null is an object
Java
DRAFT
NullPointerExceptionCompileTime
NullPointerExceptions are detected at compile time
NumericToBooleanCoercion
Numeric types can be coerced to boolean
ObjectLabeledWithConstructorSignature
In stack and heap diagrams, an object on the heap is labeled like a stack frame of a constructor call
ObjectLabeledWithVariableName
In stack and heap diagrams, an object on the heap is labeled with the name of the variable that refers to it
Java
ObjectsMustBeNamed
A variable is needed to instantiate an object
OnlyInnermostArrayElements
Only the elements of the innermost array of a multi-dimensional array are accessible
OnlyRuntimeLibraryPackages
Only the creators of the JDK can create packages
OutOfBoundsElementsAreNull
Out-of-bounds array elements are null
Java
OutsideInMethodNesting
Nested method calls are invoked outside in
Java
ParenthesesOnlyIfArgument
() are optional for method calls without arguments
PreIncrementBeforeLoop
Pre-increment in update part of for loop means increment before loop body
PrimitiveIsObject
Primitive values are heap objects
PrimitiveTypeParameter
Type parameters of generic types can be assigned primitive types
PrimitiveVariablesDynamicallyTyped
The type of a primitive variable depends on its value
PrintNewLineFirst
println(...) starts a new line and then prints
Java
DRAFT
PrivateAccessibleInSubclass
Private members of a superclass are accessible from a subclass
PrivateFieldsImplyImmutability
A class where all fields are private is immutable
Java
PrivateFromOtherInstance
An object cannot access private members of other objects of the same class
Java
PrivateFromStatic
Static methods cannot access private members of instances of same class
PrivateMeansFinal
A private field cannot be changed
RationalLiterals
Rational fractions are literals
Java
RecursiveActivationsShareFrame
Recursive calls of a method share a stack frame
RecursiveCallSiteNoReturn
Tail-recursive call sites have no continuation
Java
RecursiveMethodImpliesRecursiveType
A class with a recursive method represents part of a recursive data structure
Java
RecursiveMethodNeedsIfElse
A recursive method needs to contain an if-else statement
ReferenceIntoStack
References can point into the stack
ReferenceLabeledWithDynamicType
In stack and heap diagrams, reference variables are labeled with the types of the objects they refer to
ReferenceToBooleanCoercion
Every reference type can be coerced to boolean
ReferenceToIntegerConversion
One can cast between references and ints
Java
ReferenceToVariable
References can point to variables
ReferringToRecursiveStructureMakesRecursive
A class referring to a recursive data structure is (indirectly) part of that recursion as well
Java
ReturnCall
Return statements need () around the return value
ReturnNoOutEdge
In a control-flow graph, a return statement has no outgoing edge
Java
ReturnUnwindsMultipleFrames
A return statement can unwind multiple call stack frames
Java
RightToLeftChaining
Chained accesses are invoked from right to left
RuntimeExceptionChecked
RuntimeExceptions are checked exceptions
SemanticEquivalenceImpliesSyntacticEquivalence
Two pieces of code with the same observable behavior have to be implemented in the same way
SetterIsStatic
Setter methods are static
SingleQuoteString
String literals can be in single quotes
StackTraceIsCallHistory
A stack trace is the sequence of previously called methods
StatementMultipleOutEdges
A non-condition node in a control-flow graph can have multiple outgoing edges
StaticCallPolymorphic
A static method call is dispatched polymorphically at runtime based on the argument types
Java
DRAFT
StaticDispatch
The method to be called is determined by the static type
StaticFrameInGlobals
Stack frame of static method calls lives in the global memory area
Java
DRAFT
StringLengthField
One can know the length of a String object by accessing its length field
Java
StringLiteralNoObject
One needs to call the String constructor to get a String object from a literal
Java
StringPlusStringifiesExpression
String concatenation stringifies non-String operand expressions
Java
DRAFT
StringRepetitionOperator
The multiplication operator can repeat a String a number of times
Java
DRAFT
SubtypeCompatibleWithSupertype
A variable of a subtype can reference an object of a supertype
Java
DRAFT
SuperAlwaysHasParentheses
To call a method on a superclass, parentheses are needed after the keyword super
Java
DRAFT
SuperNotFirstStatement
super() can be called anywhere in the constructor of a subclass
Java
DRAFT
SuperclassObjectAllocated
When instantiating an object of a subclass, an object of a superclass is also allocated
Java
DRAFT
SupertypeIncompatibleWithSubtype
A variable of a supertype cannot reference an object of a subtype
TargetTyping
The type of a numerical expression depends on the type expected by the surrounding context
ThisAsField
this is a special field in the object
Java
ThisAssignable
One can assign to this
Java
ThisCanBeNull
this can be null
ThisChildInCallExpression
Instance method or constructor call nodes in expression trees have a child labeled "this"
Java
ThisExistsInStaticMethod
this is a local variable, also in static methods
ThisInConstructorIsNull
In a constructor, this is null
Java
ThisNoExpression
The name this is not an expression
ToStringPrints
Invoking toString() prints something
TryCatchMandatory
If code could throw an exception, you must surround that code with a try/catch block
TryFinishes
Exceptions get thrown at the end of the try block
UndeclaredVariables
Variables don't need to be declared
UnqualifiedNamesMustDiffer
The unqualified names of different classes must be different
UntypedVariables
Variable declarations don't need a type
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
Java
VariablesHoldExpressions
= stores an expression in a variable
Java
VariablesHoldObjects
A variable of a reference type contains a whole object
VoidMethodNotRecursive
A method with void return type can't be recursive
VoidMethodReturnsValue
A method with void return type can return a value
ZeroDigitsCompress
In integer numbers, decimal digits with value `0` take less storage than decimal digits with other values
ZeroInEdges
A control-flow graph node (other than the entry node) can have zero incoming edges
ZeroOutEdges
A control-flow graph node (other than the exit node) can have zero outgoing edges

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.