Page 198 - CTS - CSA TP - Volume 2
P. 198

COMPUTER SOFTWARE APPLICATION - CITS





           3  Class Implementation (Dog):
              •  Implements the extended interface Mammal.
              •  Provides concrete implementations for both eat and giveBirth methods.
           4  Main Class (InterfaceExtensionExample2):

              •  Creates an instance of the Dog class.
              •  Demonstrates the usage of both eat and giveBirth methods through the myDog object.
           5  Output:

















           In this example, the Mammal interface extends the Animal interface, and the Dog class implements the Mammal
           interface. It showcases how interfaces can be extended to inherit methods from a base interface while introducing
           new methods specific to the extended interface. The main method demonstrates the usage of methods from both
           the base and extended interfaces through an instance of the implementing class.

















































                                                           183
 CITS : IT & ITES - Computer Software Application - Exercise 114  CITS : IT & ITES - Computer Software Application - Exercise 114
   193   194   195   196   197   198   199   200   201   202   203