Object Instantiation and Code Examples
Classified in Technology
Written on in
English with a size of 4.2 KB
Poodle Instantiation Example
B. The Poodle variable myDog is instantiated as a Poodle. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "NoName".
Book Instantiation Example
C. Object myBook is created using the one-argument Book constructor, which uses super to set myBook's title attribute to "Adventure Story". Object yourBook is created using super to call the Publication no-argument constructor to set yourBook's title attribute to "Generic".
Tree Instantiation Example
B. Object tree1 is created using the DeciduousTree constructor, which uses super to set tree1's treeVariety attribute to "Oak". Object tree2 is created using the EvergreenTree... Continue reading "Object Instantiation and Code Examples" »