C# program exercises

C# class and constructor – programs for practice

Q) What is output of C# code? Output:Base class constructorChild class constructorExplanation: In inheritance C# oops relationship, when we create object of a derived or child class then first base class constructor then derived class constructor get called. Q) What is output of below C# code example? Output: Compiler error – constructor re-definition Compiler error […]

C# Interface – Programs for Practice

Q) What is output of C# code? Output:Saving AccountProcess saving accountExplanation: Saving Account class inherits an interface and implement its methods in the class. Note that if a class inherits an interface in C# programming, then class must implement all the methods and properties of interface or interfaces if we inherit multiple interfaces. You can […]

C# Inheritance – programs for practice

Q) What is output of below C# code? Output: Car is running Explanation: In fact, this is name hiding feature in C# language. If base class and derived class have same method name and have not used virtual and override in base and derived class respectively then on creating object of derived class and assigning […]

Scroll to top