friends,
any one guide me what is the purpose of Super class in android i have seen in many @Override methods. for example
@Override
protected void onProgressUpdate(final Object... args)
{ super.onProgressUpdate(args);
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
any help would be appreciated.
It is used to call superclass methods, and to access the superclass constructor. The most common use of the super keyword is to eliminate the confusion between superclasses and subclasses that have methods with the same name.
The superclass of a class is the class that the class was extended from, or null if it wasn't extended. for example, say you have a class called object, containing an onDestroy() method.
Definition and Usage. The super() function is used to give access to methods and properties of a parent or sibling class. The super() function returns an object that represents the parent class.
The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.
Your code would break if you called a super of a super that had no super. Object oriented programming (which Java is) is all about objects, not functions. If you want task oriented programming, choose C++ or something else.
Definitions: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).
The superclass of a class is the class that the class was extended from, or null if it wasn't extended.
for example, say you have a class called object, containing an onDestroy() method. If you then make a class based on object, called textbox, that extends(inherits) object, and thus has all the methods found in object. If you have no onDestroy() specifically for textbox, the onDestroy() inherited from object would get called, if you create your own onDestroy() to override the one from object that one will be called instead.
To make sure you are not missing important functionality that should come with textbox being an object, such as correct memory management when destroying the class, it's important to also do what would be done for an object, not only what you want to do for your textbox, this is done by calling the super.onDestroy(), which in this case would essentially call object.onDestroy().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With