C# program to implement the same abstract method in multiple classes
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 the abstract method with the same name in multiple classes is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
Here, we created an abstract class Abs that contains the declaration of method Method(). Then we created two classes Sample1, Sample2. Then we implemented the Method() in both classes.
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 reference M of Abs abstract class and then initialized M by objects of all classes one by one and call implemented methods that will print corresponding messages on the console screen.