C# program to implement multiple-inheritance using abstract class and 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 multiple-inheritance using abstract class and interface is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
Here, we created an abstract class Abs and an interfaces MyInf2, and two-parent classes Sample1, Sample2. Here we override abstract method Method1() in Sample1 class and implement Method2() of interface MyInf2 into Sample2 class. After that, we created a child class Sample3, here we inherited the Sample1 class and MyInf2 interface.
In the Sample3 class, we created the object of Sample1 and Sample2 class and here we defined two more methods Method1(), Method2(), and called Method1 of Sample1 class inside Method1() method of Sample3, and called Method2 of Sample2 class inside Method2() method of Sample3.
Now look the Program class that contains the Main() method. The Main() method is the entry point for the program. Here we created the object S of Sample3 class and called Method1() and Method2() that will print the corresponding message on the console screen.