Captainlonate
Captainlonate

Reputation: 5008

Is super's onCreate(0 called in an extended class that has no onCreate() itself?

I have a class that extends Activity like so:

public abstract class AndroidGame extends Activity implements Game

This class has an onCreate() method like this:

public void onCreate(Bundle savedInstanceState) {
 // I do stuff here
}

Then I make another class that extends AndroidGame like so:

public class ScatmanNomGame extends AndroidGame {   
    // The loading screen will load all the assets of our game
    @Override
    public Screen getStartScreen() {
        return new LoadingScreen(this);     
    }    
}

Ok, so here is my question. My default start activity (in my manifest file) is set to load ScatmanNomGame first. Upon launch of my program, the Launcher activity is ScatmanNomGame. But notice that ScatmanNomGame has no onCreate() method. Will simply starting this activity (ScatmanNomGame) call it's super class's onCreate method?

Upvotes: 0

Views: 861

Answers (1)

jeet
jeet

Reputation: 29199

Yes, It would, Read Inheritence.
Inheritence allows object of subclass to use/access public and protected fields and methods. So, If you havent overrided any method in the subclass, and invoking the same method on the object of subclass will invoke method of superclass.

Upvotes: 1

Related Questions