That really depends on the logic that the method implements. Sometimes it is called first, sometimes at the end, and sometimes never. For example, if some calculation from superclass method is really important, then it will be called first. Or if calculation is attempted in subclass method but without a good result (result is null) attempt is made on subclass method. There is really no good answer to this question except that it really depends.
Example 1:
A label provider that extrapolates time from the Date
object and returns it to the UI for showing:
public class TimeLabelProvider {
public String getText(Date element) {
//extrapolate time from the element
return time;
}
}
A label provider that extrapolates both date and time from the Date
object and returns it to the UI for showing:
public class DateTimeLabelProvider extends TimeLabelProvider {
@Override
public String getText(Date element) {
//extrapolate date from the element
String date = ...
//now get time string. We don't need to repeat logic,
//its already implemented in super method!
String time = super.getText(element);
return date + " " + time;
}
}
Example 2:
If your project has a deep class hierarchy for UI elements, e.g.
DropDownField extends TextField extends Field extends AbstractField
Now, each of the classes added some UI elements to the field, for example, DropDownField
added a menu and a little arrow to the right of the field, TextField
added a validator, AbstractTextField
added a white block to write text, etc... To dispose elements you would have to do multilevel disposal like this:
public class DropDownField extends TextField {
@Override
public void dispose() {
menu.dispose();
arrow.dispose();
//let text field dispose of its elements
super.dispose();
}
}