polymorphism
12 tutorials tagged “polymorphism”.
- Compile-Time Polymorphism in JavaCompile-time (static) polymorphism through overloading: how the compiler fixes the method before the program runs, shown in the bytecode.
- Covariant Return Type in JavaAn overriding method may return a subtype of the parent's return type. How it removes casts, its limits, and the bridge method the compiler adds.
- Runtime Polymorphism and Dynamic Method DispatchHow the JVM picks an overriding method at runtime: the lookup from the object's class upward, a mixed Shape array, invokevirtual and method tables.
- Exception Handling with Method OverridingWhat an overriding method may and may not declare in throws, why broader checked exceptions are forbidden, and the matching rule for constructors.
- Java Instanceof and Pattern MatchingTest an object's type with instanceof, then let pattern matching declare the cast variable for you: binding variables, flow scoping and null.
- Polymorphism in JavaOne call, many behaviors: what polymorphism means, its compile-time and runtime forms, and why it lets you add new types without changing old code.
- Can Static, Private and Final Methods Be OverriddenWhy static, private and final methods can't be overridden, what method hiding is, and why fields follow the variable's type instead of the object.
- Method Overloading in JavaSeveral methods with one name and different parameters: how the compiler picks one, the widening-boxing-varargs order, and ambiguous calls.
- Rules of Method OverridingThe exact rules an overriding method must follow: signature, return type, access, checked exceptions, and which methods can't be overridden.
- Method Overriding in JavaA subclass replaces an inherited method with its own version: how overriding works, @Override, reusing the parent with super, and a silent typo bug.