Overridden methods in Java Overridden methods of super class in subclass allow a class to inherit and behave close enough. To avoid naming conflict and signature and type and number of parameters for a specific functionality that of a super class, the overridden methods are utilized.
Every class is a descendent of the Object class. This class contains toString() method which returns a String object and its hash code. Most of the methods need to override this method.
For example the method System.out.println() will be overridden by toString() before displaying the result on the screen. Another example: the Stack class overrides the method toString() when it pops an object.
|