Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is Interface and Abstraction (in real time scenario)

Answers were Sorted based on User's Feedback



What is Interface and Abstraction (in real time scenario)..

Answer / pratap kumar jna

Interface:
1.Through interface we achive the multiple inheritance...i
meeans one class can implmemnts multiple interface.
2.Interface only contains abstract method means only
signature part..

LIKE int method1(int x,int y);

3.we achive actual run time polymorphism....

ABSTRACT :

Abstract class contain abstract and concrate mthod..

class can inhrit only one abstarct class..

Is This Answer Correct ?    10 Yes 4 No

What is Interface and Abstraction (in real time scenario)..

Answer / tams

1.Interface is a kind of plug in adapter by which different
classes can be benefited differently while abstarct class
comes in a role when idea of whole class is not much clear
intially like which method should be or not like a
practical planing.
2.so we can say abstract class is a kind of place holder
class and inherited by similar classes abstarct methods
must be declared/defined in the derived class while in
interface you can go for any methods

Is This Answer Correct ?    7 Yes 6 No

What is Interface and Abstraction (in real time scenario)..

Answer / amitabh

Better Explanation Here

http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx

Is This Answer Correct ?    3 Yes 3 No

What is Interface and Abstraction (in real time scenario)..

Answer / satish

Interface:

–> If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.

For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.

–> If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces.

For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO .

Abstract Classes

–> When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.

For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.

–> The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share.

For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.

Use an abstract class

When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)
Use an abstract class to define a common base class for a family of types.
Use an abstract class to provide default behavior.
Subclass only a base class in a hierarchy to which the class logically belongs.


Use an interface

When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
Use an interface to design a polymorphic hierarchy for value types.
Use an interface when an immutable contract is really intended.
A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Sharp Interview Questions

If a method's return type is void, can you use a return keyword in the method?

0 Answers  


Which compiler switch creates an xml file from xml comments in the files in an assembly?

0 Answers   Siebel,


Does c# support templates?

0 Answers  


What is a pre-requisite for connection pooling?

2 Answers  


What are the Features in .net framework 1.1

0 Answers   Digital GlobalSoft,


What is a reference type c#?

0 Answers  


Asha buys 16 Chocolates for rs 12 and 24 chocolates for rs 20, if she sold them 30 chocolates for rs 30 then what is the Gain/Loss percentage? Gain(700/19 %) Loss(700/19 %) Gain(500/19 %) Loss(500/19 %) If one person ate 100 grapes in 5 days and 6 more each day from starting, what was the no of grapes he ate on first day? 6 8 10 7 If seven men P, Q, R, S, T, U, V parked his car, P and Q something like that. 6 student J, K, L, M, N, O went for picnic in 2 batches, K and L have to go together, M and O do't go together, if O and L go in one batch then which of these combination will be wrong. Jmnp Jklo klop JKLO a boat can go upstream and down stream, if it goes 5/2 times of downstream at the speed of 6 kmph then what will be the speed of upstream? 15 KMPH 12 KMPH 10 KMPH 11 KMPH A, B, C, D, E sitting on a table, A sits 2 seat left from B and C sits 2 seat right from B then what will not be the combination ACDE

0 Answers   Symphony,


Is exe is machine dependent?

0 Answers  


what kind of questions (.net)to expect in a telephonic interview.This is the first time i will be facing a tele interview .Any inputs regarding this??

2 Answers   iNube Software Solutions,


What is dto c#?

0 Answers  


What are class fields?

0 Answers  


What is executereader in c#?

0 Answers  


Categories