Skip to main content

Posts

Showing posts from December, 2017

Why We Should Follow Method Overriding Rules

In my previous articles  Why Should We Follow Method Overloading Rules , I discussed about method overloading and rules we need to follow to overload a method. I have also discussed why we need to follow these rules and why some method overloading rules are necessary and others are optional. In a similar manner in this article, we will see what rules we need to follow to override a method and why we should follow these rules. Method Overriding and its Rules As discussed in  Everything About Method Overloading Vs Method Overriding , every child class inherits all the inheritable behaviour from its parent class but the child class can also define its own new behaviours or override some of the inherited behaviour. Overriding means redefining a behaviour (method) again in the child class which was already defined by its parent class but to do so overriding method in the child class must follow certain rules and guidelines. With respect to the method it overrides, the overriding method must

Why Should We Follow Method Overloading Rules

In my previous articles, Everything About Method Overloading Vs Method Overriding and  How Does JVM Handle Method Overloading and Overriding Internally , I have discussed what is method overloading and overriding, how both are different than each other, How JVM handles them internally and what rules we should follow in order to implement these concepts. In order to overload or override a method we need to follow certain rules, some of them are mandatory while others are optional and to become a good programmer we should always try to understand the reason behind these rules. I am going to write two articles where I will try to look into the method overloading and overriding rules and try to figure out why we need to follow them. In this article, we will see what rules we should follow to overload a method and we will also try to know why we should follow these rules. Method Overloading In general, method overloading means reusing same method name to define more than one method but all