Showing posts with label toString. Show all posts
Showing posts with label toString. Show all posts

Wednesday, September 18, 2013

Overriding Methods

A child class can override concrete methods from the parent. This is done by precisely duplicating the parent's method signature, in the child.

Let's override the toString() method which our class inherits from the Object class:




Here's the call:




Here's the output:




When overriding, ensure the method signature is reproduced perfectly.

Here's a cat.