1
Reply

How do you achieve polymorphism without using overridding and overloading?

    we can achieve polymorphism using interfaces

    with out overloading & overriding.

    in interface we can one method  and implement this method in two different classes.

    we can refer the interface name and store the class objects .

    we can call the method depending on object creation of class.

    interface xyz

    {

    public void print();

    }

    class a:xyz

    {

    public void print()

    {

    console.writeline("method a");

    }

    }

    class b:xyz

    {

    public void print()

    {

    console .writeline("method b");

    }

    }

    class test

    {

    public static void Main()

    {

    xyz obj;        //refer the interface

    obj=new a();

    obj.print();// o/p :method a

    obj=new b();

    obj.print();//o/p: method b

    }

    }

    17y
    0