Super keyword in Java- Java Key Points

In Java super keyword has two main uses

1)The first calls the superclass’ constructor.

2)The second is used to access a member of the superclass that has been hidden by a member of a subclass.

1)The first calls the superclass’ constructor.

super( ) must always be the first statement executed inside a subclass’ constructor.

When a subclass calls super( ), it is calling the constructor of its immediate superclass.

2)The second is used to access a member of the superclass that has been hidden by a member of a subclass.

This second form of super is most applicable to situations in which member names of a subclass hide members by the same name in the superclass.

Advertisements

One thought on “Super keyword in Java- Java Key Points

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s