I have a stupid confusion, when we override the parent class method then does this derived overridden method still hold the code of parent class method, or it is a new fresh method which we can define?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Read this article to get concept clear. http://docs.oracle.com/javase/tutorial/java/IandI/override.html
Generally we do when we want to extend the method of super class or to want to change the complete logic.
For ex: Super class have sorting method which use bubble sort.
In Derived class you want to take same method but want to implement quick sort. Then we do overriding.
Second
If you want to execute super class method first then your sub class overriden method logic then we use
super.methodname().Last to point of your question If you override the method and not called super class method like
super.method()then its not mean its fresh method. Its means I already explain the sort example.