Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Java

Method Overriding in Java

Replace a parent method in a subclass with @Override.

Method Overriding in Java — a practical guide to Java method overriding with clear examples you can reuse in real projects.

Java Tutorial Series (40/90). Prefer one article? Read the complete Java tutorial.

Short description

Overriding enables runtime polymorphism. Signatures must match rules for covariant returns/exceptions.

Override

class Printer {
    void print() { System.out.println("base"); }
}
class PdfPrinter extends Printer {
    @Override
    void print() { System.out.println("pdf"); }
}

Leave a reply

Your email address will not be published. Required fields are marked *