Programming Example of C# Polymorphism

example

Qu 1. Write a program to save data to database. There should be a function Save() that accepts one, two or three values as parameter and then save that to database.
Answer

Output

No Data to Saved
Jack saved
Jack and 22 are saved on 19-11-2016
_



  • Qu 2: Write a program using virtual and override keyword in which base class should have a function TyreSize() that should be implemented in derived class using override keyword.
    Answer

    Output

    Default Tyre Size is 13 Inches
    Tyre Size is Overriden and new Tyre Size is : 14 Inches
    _

    Summary

    In this chapter you learned Polymorphism using some programming example. In the next chapter there are some programming questions. You must solve that question using programming techniques.


    Leave a Reply

    Your email address will not be published. Required fields are marked *