Chapter 9 Object-Oriented Programming: Inheritance 371 34 35 (Web hosting compare)
Chapter 9 Object-Oriented Programming: Inheritance 371 34 35 // display Cylinder’s Circumference 36 output += “Circumference is ” + 37 String.Format( “{0:F}”, cylinder.Circumference() ) + “n”; 38 39 // display Cylinder’s Area 40 output += “Area is ” + 41 String.Format( “{0:F}”, cylinder.Area() ) + “n”; 42 43 // display Cylinder’s Volume 44 output += “Volume is ” + 45 String.Format( “{0:F}”, cylinder.Volume() ); 46 47 MessageBox.Show( output, “Demonstrating Class Cylinder” ); 48 49 } // end method Main 50 51 } // end class CylinderTest Fig. 9.16 Fig. 9.16Fig. 9.FiFi16g. 9.16g. 9.16Testing class Cylinder(Part 2 of 2.). 9.6 Constructors and Destructors in Derived Classes As we explained in the previous section, instantiating a derived-class object begins a chain of constructor calls in which the derived-class constructor, before performing its own tasks, invokes the base-class constructor either explicitly or implicitly. Similarly, if the base-class was derived from another class, the base-class constructor must invoke the constructor of the next class up in the hierarchy, and so on. The last constructor called in the chain is class Object s constructor whose body actually finishes executing first the original derived class s body finishes executing last. Each base-class constructor initializes the base-class instance variables that the derived-class object inherits. For example, consider the Point3/Circle4hierarchy from Fig. 9.12 and Fig. 9.13. When a program creates a Circle4object, one of the Circle4 constructors is called. That constructor calls class Point3 s constructor, which in turn calls class Object s constructor. When class Object s constructor completes execution, it returns control to class Point3 s constructor, which initializes the x-y coordinates of Circle4. When class Point3 s constructor completes execution, it returns control to class Circle4 s constructor, which initializes the Circle4 s radius.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.