When should we use abtract class and Interface Class?Give
an Example

Answer Posted / pallavi

Use an abstract class when you want to inherit only from the parent
Use an interface when you want to inherit from multiple sources
If the behaviour of base class is default behaviour of all the sub classes the use abstract. If it is not default behaviour for all the classes use interface.
Interface - CAN-DO relationship
abstract class - IS-A relationship

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is inproc and outproc?

525


How to add DateTime Control in normal DataGrid Server Control?

584


Can we use a static function with a non-static variable?

510


What is role-based security in asp.net?

525


What is page fragment caching?

556






What is server side routing?

511


Which is faster viewbag or viewdata?

568


What is a session http?

521


What is viewstate? What does the “enableviewstate” property do?

526


How do we sort the data from a dataset?

575


What is the parent class of all web server control?

539


Why cyclomatic complexity is important?

564


Which platform does Microsoft .NET use for exchanging data between applications?

589


Can you change a master page dynamically at runtime? How?

510


What is the difference between session object and application object?

594