java4all@1986 java. Powered by Blogger.

How do we call the super class Constructor?

>> Sunday, May 29, 2011

If a class called “SpecialPet” extends your “Pet” class then you can
use the keyword “super” to invoke the superclass’s constructor.

public SpecialPet(int id) {
super(id); //must be the very first statement in the constructor.
}

To call a regular method in the super class use: “super.myMethod( );”. This can be called at any line. Some
frameworks based on JUnit add their own initialization code, and not only do they need to remember to invoke

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP