Some Rules of Method Overriding are as follows :
- Methods must have same name.
- Methods must have same number of argument list.
- Method must have same return type.
- Only public, protected and default(same package) methods can be overridden.
- If method has default access, then overriding method must be default, protected or public.
- If method has protected access, then overriding method must be protected or public.
- If method has public access, then overriding method must be public.
- Final methods cannot be overridden. Because final is used to declare constant.
- Static methods cannot be overridden. Because static method is available to all instance of super class and sub class.So it's not permissible to re-implement the static method in sub class.
- Use super keyword to invoke the parent class method from sub class.
- Constructor can not overridden.
- The synchronized modifier has no effect on the rules of overriding.
- The strictfp modifier has no effect on the rules of overriding.
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.


No comments:
Post a Comment