How does VB.NET/C# achieve polymorphism?

Answer Posted / deep

Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also describe the methods that a class needs to implement. The difference between abstract classes and interfaces is that abstract classes always act as a base class of the related classes in the class hierarchy. For example, consider a hierarchy-car and truck classes derived from four-wheeler class; the classes two-wheeler and four-wheeler derived from an abstract class vehicle. So, the class 'vehicle' is the base class in the class hierarchy. On the other hand dissimilar classes can implement one interface. For example, there is an interface that compares two objects. This interface can be implemented by the classes like box, person and string, which are unrelated to each other.

C# allows multiple interface inheritance. It means that a class can implement more than one interface. The methods declared in an interface are implicitly abstract. If a class implements an interface, it becomes mandatory for the class to override all the methods declared in the interface, otherwise the derived class would become abstract.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we use asp.net for website development?

500


What is a postback in asp net?

541


How is a session stored and maintained in asp.net?

537


Which is faster union or union all?

582


How can exception be handled with out the use of try catch?

549






Is there any alternative to avoid name collisions other then Namespaces?

575


Write a code for sending an email from asp.net application.

540


Why viewstate is used in asp.net?

511


What is asp net objects?

525


Explain the main differences between asp and asp.net?

519


What are the uses of reflection?

579


how to debug web services on consumer side?

581


Define viewstate in .net?

546


What is the viewstate in asp.net?

573


What are the new features added from ASP to ASP.NET?

573