In a hierarchy of subclasses, when you use "super" in the constructor, which constructor does it actually call? The superclass immediately above, or the one all the way at the top?
What would be the point of using "this" in the definition of a constructor
Since abstract classes can't be instantiated, are they mainly/only used as a blueprint for subclasses?
Also, not sure I can grasp why we should create a variable, type abstract...
All things are lawful, but not all things are profitable.
The good news is, it is all in the Java Language Specification (=JLS). The bad news is, the JLS can be really difficult to understand. Simply: immediately above, and that calls super immediately above, etc. until you get to java.lang.Object.Danny Treart wrote: . . .
In a hierarchy of subclasses, when you use "super" in the constructor, which constructor does it actually call? The superclass immediately above, or the one all the way at the top?
It allows you to call new Foo() and that sets default values. If you write the assignments in both constructors, you are repeating yourself.What would be the point of using "this" in the definition of a constructor, just to call a different constructor of the same class? It seems unnecessary, but that is just because I'm not fully understanding it I'm sure? . . .
What is a clone instructor? A copy constructor allows an object to duplicate itself easily. Look at this thread. Find a copy of Effective Java™ by Joshua Bloch and it tells you about copying objects. Also that the clone method is poor design.
Can anyone tell me what the importance is of creating a copy constructor? A clone instructor? . . .
Mainly as a blueprint for subclasses, yes. They can be instantiated, but you need a bit of fiddling to convert them to anonymous classes.
Since abstract classes can't be instantiated, are they mainly/only used as a blueprint for subclasses? . . .
the clone method is poor design.
All things are lawful, but not all things are profitable.
Campbell Ritchie wrote:What is a clone instructor?
Danny Treart wrote:...but seriously, what is a clone instructor?! o.O
Ron McLeod wrote: . . .
According to Wookiepedia, the Clone Instructors . . .
That sounds incorrect. The clone() method returns a shallow clone by default but can be overridden to return a deep clone. You also have to implement Cloneable.Knute Snortum wrote: . . .
I think the idea was that a copy constructor makes a shallow copy . . . and a clone would make a deep copy . . .
Ron McLeod wrote:
Danny Treart wrote:...but seriously, what is a clone instructor?! o.O
According to Wookiepedia, the Clone Instructors were Mandalorian mercenaries recruited by Jango Fett to train the Clone Army.
All things are lawful, but not all things are profitable.
Good heavens! What have you done! Here, try to fix it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|