giddee up
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
May the force of the Java be in all of us !!!
giddee up
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
giddee up
giddee up
giddee up
giddee up
May the force of the Java be in all of us !!!
giddee up
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Dirk Schreckmann:
then the compiler fills it in with a call to the default constructor in the super class.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
giddee up
Originally posted by Jasper Vader:
My assumption is that if a class is to be subclassed, then it MUST have a no-args constructor either implicitly or explicitly defined in it, so that the subclass can call that no-args constructor (with whatever constructor that subclass might be using at the time, even an args constructor).
I just wonder why this is.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
giddee up
Originally posted by Sri Sri:
The no arg contructor is being called because you did not explicitly call the args constructor in super class by using the super keyword.
giddee up
Originally posted by Sri Sri:
If you change it to
Sub(int i)
{
super(i);
}
then, instead of the no-arg super constructor, the superclass constructor that takes in an integer is called.
giddee up
giddee up
Originally posted by Kathy Sierra:
Just for a little more clarification... at Sun Education, in Java, we usually *do* use the terminology Ilja mentioned, to make it simple.
The Java spec uses the term, "the default constructor" to *always* mean "the one provided by the compiler" (which of course is always no-arg). You *could* still say that you have "A" default constructor, which doesn't necessarily mean it is "THE" default constructor, but to keep it clear, we have adopted the convention of making a distinction between "the default constructor" and "a no-arg constructor".
We do this, I believe, because we're too lazy to use the rest of the sentence, "the default constructor provided by the compiler" vs. "the default constructor YOU wrote".
It's just simpler to say "default" to mean "compiler-generated" and "no-arg" to mean either human OR compiler-generated.
And though it might not matter much in this forum, the use of the terminology I've described here is the way we refer to it in the Programmer certification exam.
Cheers,
Kathy
implements Lazy
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|