C# program to inherit an abstract class and interface in the same class
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 inherit an abstract class and interface in the same class is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
Here, we created an interface Inf and an abstract class Abs. The abstract class Abs contains a declaration of Method1() and the interface Inf contains a declaration of Method2(). Then we inherited the abstract class and interface in the Sample class.
Now look to the Program class that contains the Main() method. The Main() method is the entry point for the program. In the Main() method, we created the reference of abstract class and interface, both are initialized by the object of the Sample class. After that, we called Method1() and Method2() that will print appropriate messages on the console screen.