vb_student
Oct 26th, 2006, 10:38 AM
Hello
I was reading about the construction of constructors and this article says
The first thing that happens inside the constructor is that the constructor of the class's superclass is called.
Then, each class attribute of the object is initialized. These are the attributes that are part of the class definition (instance variables), not the attributes inside the constructor or any other method (local variables). In the DataBaseReader code presented earlier, the integer startPosition is an instance variable of the class.
Then, the rest of the code in the constructor executes.
(http://www.developer.com/design/article.php/10925_3516911_3)
if there are any local variables to the superclass, will these variables be initialised in the constructor of the superclass.
w.e. if we have two classes dog and cat each derived from a superclass animal. will variables to do with say number of legs = 4 be initialised within the seuperclass animal?
I was reading about the construction of constructors and this article says
The first thing that happens inside the constructor is that the constructor of the class's superclass is called.
Then, each class attribute of the object is initialized. These are the attributes that are part of the class definition (instance variables), not the attributes inside the constructor or any other method (local variables). In the DataBaseReader code presented earlier, the integer startPosition is an instance variable of the class.
Then, the rest of the code in the constructor executes.
(http://www.developer.com/design/article.php/10925_3516911_3)
if there are any local variables to the superclass, will these variables be initialised in the constructor of the superclass.
w.e. if we have two classes dog and cat each derived from a superclass animal. will variables to do with say number of legs = 4 be initialised within the seuperclass animal?