Glossary
@Override annotation
A Java annotation used to explicitly indicate that a method in a subclass is intended to override a method in its superclass. It helps the compiler check for correct overriding.
Example:
When implementing a custom toString() method in your Student class, you'd place @Override annotation above it to ensure you're correctly redefining the Object class's toString() behavior.
Overloading
Defining multiple methods within the same class that have the same name but different parameters (different number or types of arguments).
Example:
A Calculator class might have an add method that takes two integers (add(int a, int b)) and another overloading add method that takes two doubles (add(double a, double b)).
Overriding
Redefining a method in a subclass that already exists in its superclass, using the exact same method signature (name, return type, and parameters).
Example:
A Dog class might override the makeSound() method inherited from its Animal superclass to specifically bark() instead of a generic sound.
Subclass
A class that extends another class, inheriting its public methods and properties. It can add new functionalities or modify inherited ones.
Example:
In a game, a Warrior class could be a subclass of a Character class, inheriting basic health and movement but adding unique combat abilities.
Superclass
A class from which other classes (subclasses) inherit methods and properties. It serves as a base or parent class.
Example:
If Car and Truck are classes, Vehicle would likely be their superclass, defining common attributes like speed and color.