how do I know when/where to invoke the overridden method of the super class

Posted by Henry on Stack Overflow See other posts from Stack Overflow or by Henry
Published on 2010-04-14T11:27:55Z Indexed on 2010/04/14 11:33 UTC
Read the original article Hit count: 429

Filed under:
|

Hi,

This question occured to me while programming a Android application, but it seems to be a general programming question more.

The situation is, I am extending (subclass-ing) an class from a library, and overriding a method. how do I know if I should invoke the method of super-class? and when? (in the beginning of the overridden method or in the end?)

For example, I am overriding the method "public boolean onCreateOptionsMenu(Menu menu)" from class "Activity" in Android platform. And I saw someone write "return super.onCreateOptionsMenu(menu)" in the end of the method, in an example. But how do I know it should be done this way? and it is correct or not? what's the difference if I begin my method with "super.onCreateOptionsMenu(menu)"?

BR, Henry

© Stack Overflow or respective owner

Related posts about java

Related posts about android