Glossary
Dynamic Type
The actual type of the object that a variable refers to at runtime, determined by the constructor call. This type dictates which overridden non-static methods are executed.
Example:
In Shape s = new Circle();
, Circle
is the dynamic type of the object referenced by s
.
Non-static Method
Also known as an instance method, this method belongs to an object instance and operates on that object's data. When called via a variable, its behavior is determined by the object's dynamic type.
Example:
If you have a Dog
object myDog
, calling myDog.bark()
invokes a non-static method specific to that dog instance.
Override
When a subclass provides its own specific implementation for a method that is already defined in its superclass. This allows for polymorphic behavior.
Example:
A Cat
class might override the makeSound()
method inherited from Animal
to print 'Meow!' instead of 'Generic animal sound'.
Polymorphism
A core object-oriented programming concept where objects can take on multiple forms, allowing a single variable to refer to objects of different types at different times, influencing method behavior.
Example:
In a game, a Vehicle
variable could hold a Car
object or a Motorcycle
object, demonstrating polymorphism.
Static Method
A method that belongs to the class itself, not to any specific object instance. It is called using the class name or, if called via an object reference, its behavior is determined by the variable's static type.
Example:
A utility class might have Math.abs(-5)
where abs
is a static method of the Math
class.
Static Type
The type that a variable is declared as at compile time. It determines which methods can be called on the variable without compilation errors.
Example:
In Animal myPet = new Dog();
, Animal
is the static type of the myPet
variable.
Superclass
A class from which other classes inherit properties and methods. It serves as a parent class in an inheritance hierarchy.
Example:
In a hierarchy where Car
and Motorcycle
extend Vehicle
, Vehicle
is the superclass.