Monday, August 10, 2015

Now a days, a very simple but tricky question "How to Prevent Method Overriding in Java" is asked in interview.
Many of us just answer that final keyword is used to prevent overriding but there are 2 more ways to prevent overriding.
1. final
2. private
3. static
Generally, we answered only first one i.e. final keyword but make sure to answer properly (mentioned all 3 ways) to impress interviewer. Interviewer knows that all are familiar with final and they ask this question to know whether you know about other 2 ways or not.
So, don't take this question easily and make sure to explain all three, if this question is asked in interview.
Keep exploring Java.

No comments:

Post a Comment