C# program to implement hierarchical inheritance using the interface
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to implement hierarchical inheritance using interfaces is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
Here, we created an interface MyInf that contains the declaration of Method1(). Then we implemented the interface in the Sample1 class. After that Sample1 class is inherited by Sample2 and Sample3 classes. The Sample2 and Sample3 classes also contain extra methods.
Now look to the Program class, It contains the Main() method, the Main() method is the entry point for the program. Here we created the objects of Sample2 and Sample3 classes. Then we called all methods that will print the corresponding message on the console screen.