CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS MICROSOFT C# DETAILS
    Question :
    Real life examples of polymorphisms, encapsulation and inheritance?

    Posted by: CRP on 6/19/2008

    Contact CRP Contact CRP
    Category C# Interview Questions
    Rating (0.4) By 2153 users
    Added on 6/19/2008
    Views 3549
    Rate it!
    Answers:

    polymorphisms:-
    polymorphisms is nothing but ability to take more than one forms(One Interface,Multiple Methods or One Name,Many Forms).

    Encapsulation:-
    -is nothing but wrapping the data and functions into single entity.

    Inheritance:-
    The Process of deriving new class from existing class.This is called Inheritance.
    New Class-Child Class
    Existing Class-Parent Class

    Types:
    *Single Inheritance
    *Multiple
    *Hybrid
    *Multilevel
    *Hierarchical





    Posted by: krishnasamy    

    Contact krishnasamy Contact krishnasamy

    Hey, It asks for real world examples...

    Polymorphism:

    say a door..
    a door to a temple, a door to a house, a door to a kitty house,
    all are doors, but all look different

    Encapsultion:

    cars and owners...
    all the functions of cars are encapsulated with the owners..
    No one else can access it...


    Inheritence:

    Kingfisher jet
    ^
    |
    Airplane
    ^
    |
    Flying Things



    Posted by: Jk    

    Contact Jk Contact Jk

    polymophism ...good example is when dog smells a cat it will barkand run after it but when it smells food it it will salivate and run to its bowl.ie .sence of smell is at work in both situations but action depends upon what it smells.



    Posted by: raseeka    

    Contact raseeka Contact raseeka

    polymorphism:
    Poly = many
    morphs = forms
    existing in many forms.
    It is achieved by OVERLOADING and OVERRIDING.

    EXAMPLE: We behave diffrently in front of elders, and friends.
    a single person is behaving diffrently at diffrent time.

    ENCAPSULATION:
    Wrapping up data and member functions in a single unit for easier and safer access.

    INHERITANCE:
    A new class(child) can be based on existing class(parent) deriving functionallity from parent class.



    Posted by: Prasana J    

    Contact Prasana J Contact Prasana J

    Polymorphisam: An Object is in different forms and in each form its exhibit the same functionality but the implementation is different.

    Eg: A Person who knows more than two languages he can speak in a language which he knows. Here person is Object and speak is polymorphisam.

    Inheritance: The process of eqiring the existing functionality of parent and with new added features and functionality of a child Object.

    A secintific calculator is a extend form of Caluculator here Caluculator is parent and secintific calculator is Child object.

    Encapsulation: Binding of data and behavior i.e functionality of an object in a secured and controlled manner.



    Posted by: Nageswara Rao    

    Contact Nageswara Rao Contact Nageswara Rao

    real life exam :
    polymorphisam.it is phenominal used for one interface multiple function. girl like a friend,girlfiriend,daughter
    inhertance.it is a property in which derived class inherits feauters of base class.like father and son
    encapsulation.encapsule only relevent information.line vaccum cleaner



    Posted by: sunil    

    Contact sunil Contact sunil

    IT IS REALLY GOOD QUESTION

    POLYMORPHISAM MEANS HAVE SAME FORMS WITH DIFFERENT METHODS

    EXAMPLE MAN EAT FOOD, MAN DRINK WATER.

    HERE MAN IS THE FORM HAVING WITH SAME NAME
    FOOD AND WATER IS THE METHODS


    ENCAPSULATION MEANS HIDING ALL THE INTERNAL DETAILS OF THE METHODS.

    EXAMPLE cars and owners...
    all the functions of cars are encapsulated with the owners..
    No one else can access it...

    INHERITANCE MEANS A CHILD CLASS USE THE ALL THE ELEMENTS IN THE PARENTS CLASS.

    DAD
    ||
    CHILED



    Posted by: rajeshkumarreddy challa    

    Contact rajeshkumarreddy challa Contact rajeshkumarreddy challa

    EX OF POLYMORPHISM:
    A TEACHER BEHAVES TO STUDENTS
    A TEACHER BEHAVES TO HIS/HER SENIORS
    HERE TEACHER IS AN OBJECT BUT ATTITUDE IS DIFFERENT IN DIFFERENT SITUATIONS



    Posted by: Manjog Padhy    

    Contact Manjog Padhy Contact Manjog Padhy

    polymorphism: poly=many
    morphism=forms
    i.e one interface having many methods.
    human being
    encapsulation: hiding the information of essential detalis.
    inheritance: the process of deriving one class from parent class.



    Posted by: tejaswini    

    Contact tejaswini Contact tejaswini

    Polymorphism means ability to take more than one form thats an operation can exhibit different behavior at different instance depend upon the data passed in the operation
    the real life example
    A software engineer can perform different task at different instance of time depending on the task assign to him
    he can done coding , testing , analysis and designing depending on the task assign and the requirement



    Posted by: Deepesh Yadav    

    Contact Deepesh Yadav Contact Deepesh Yadav

    real life example of Polymorphism,encapsulation and inheritance.

    polymorphism-which have more than one form and perform different task....... just like commonwealthgames statium(only one stadium but it perform number of task.

    inheritance-which extends the freatures of base class. just like
    grandFather
    |
    Father
    |
    son
    encapsulation-wrapping of data in single unit. just like ..... hide of data
    example
    u hv moblie phone.... there it some interface which helps u to interact with cell phone and u can uses the services of moblie phone. But the actually working in cell phone is hide. u dont know how it works internally.


    i hope u get wht u want.....
    if not then u can msg and time 24/7

    rajiv here




    Posted by: rajiv    

    Contact rajiv Contact rajiv

    there are three pillar object oriented programming language.
    and that is Polymorphism, Inheritance and encapsulation.

    polymorphism- mean which have more than one form and do different task.
    its real example
    just like stadium of common wealth games. Single stadium but it perform multiple task.
    like swimming, lawn tennis etc.

    Inheritance- which extends the property of base class into the drive class.
    example grandfather-father-son.

    Encapsulation- wrapping of data into single unit that is object and hide of data too.
    example- take a example of mobile phone.
    mobile phone have some interface which helps human to access the service of mobile but u do not know internal working of cell phone.
    i hope it helps you. if not then you can message me or call me any time
    8800576148



    Posted by: rajiv     

    Contact rajiv Contact rajiv

    POLYMORPHISM-
    poly means "MANY" ,
    morphism means "FORMS"..
    MEANS many forms
    or u can say that a object(person,place or thing) acts differently in different situations
    example-
    if a girl is married and mother of 2 children doing teaching job den
    she is a women first ,, teacher in a school whn she is in school,,wife of someone at home,, mother of her children,, and obvious daughter of someone & may be girl friend of someone (just kidding) means a woman plays diffent roles at different times dats the polymorphism (many forms)
    now overloading is achivd in c# by two ways a)method overloading also called compile time polymorphism
    b)method overridind also known as run time polymorphism.
    ======================
    inheritence= means to inherit(adopt) the feature/functionality of base class and also add their own functionality..
    EXMPLE- a child inherit(adopt) some features of their parents & also add some features of their own
    ENCAPSULATION-means hide/bind something ex- a capsule (which we consume whn v r ill)hide/bind some powder form in itself,, means that capsule encapsulate the powder contained it.
    or the best example of encapsulation is a CLASS becoz a class hides class variables/functions from outside d class..

    i hope u get wht u want.....
    if not then u can msg and time 24/7

    9968749782 or email me gaurav.datta1985@gmail.com



    Posted by: Gaurav Datta    

    Contact Gaurav Datta Contact Gaurav Datta

    Polymorphism:
    many forms exits with same name...
    The real world example for the polymorphism is people.
    many people can have the same name but their mentalities should be different.



    Posted by: reddy    

    Contact reddy Contact reddy

    it is very good articule for understaning the concepts of oops.......



    Posted by: Nitin    

    Contact Nitin Contact Nitin

    Real life experience :-
    Inheritance :- Parents/child relationship.
    If parent is a base class and child is a derived class, then child inherites properties from it's parents and include it's own properties.

    Thanks.



    Posted by: Manjushree     

    Contact Manjushree Contact Manjushree

    Real time examples:
    Polymorphism: One function behaves different forms. Ex:Person behaves SON in house at the same time that person behaves EMPLOYEE in office.

    Encapsulation: Binding data and functions. Ex: Medical Capsules.

    Abstraction: Hiding unnecessary data. Ex: Functionalities of a CAR.



    Posted by: alishaik    

    Contact alishaik Contact alishaik

    polymorphism:
    A human is a example for polymorphism.. for eg: take a sudent he act as a student in college,act as a son in home,act as a brother/sister

    encapsulation:
    It is wrapping of data into a single unit.

    eg:
    take a washing machine we know how to use it..... but we dont know actually what it's doing internally..



    Posted by: Thulasiram.    

    Contact Thulasiram. Contact Thulasiram.

    Polymorphism can better be understood in dynamic context(though static polymorphism happily exists in object-oriented paradigm)

    Polymorphism:
    -------------
    Using the same INSTRUCTION take DIFFERENT kind of ACTION depending on CONTEXT.

    "go and refresh" instruction takes you to the restroom, but you may end up only with washing your hands and face as taking a shower or steam bath are not available options in this office building. Otherwise, BINGO !!

    So, "go and refresh" -> wash your hands and face (only this option is left for you)

    "go and refresh" -> take a shower (as gallons of water available and you have a party tonight)

    "go and refresh" -> take a steam bath (gonna walk the red carpet!)

    Encapsulation:
    --------------
    I am sponge. My name is Bob. Patrick calls me SpongeBob. Patrick is my best friend. I can cook. I wear Square Pants. I am the SpongeBob.

    Inheritance:
    ------------
    Toyota Car
    |
    |
    Corolla------Camry-----Prius
    |
    |
    Corolla Hybrid



    Posted by: SpongeBob SquarePants    

    Contact SpongeBob SquarePants Contact SpongeBob SquarePants

    polymorphism
    it means an opeartor or a thing to perform more than one form or take more than one form
    e.q.
    + in the case of integers do addition
    but in case of strings concatenation



    Posted by: beerpreet    

    Contact beerpreet Contact beerpreet

    inheritence:
    real world ex:your sir name which you inheritece(use the properties and behaviour)and use with your name.



    Posted by: jatin    

    Contact jatin Contact jatin

    So many Stupid answers!!


    Encapsulation:

    Class Account
    {
    private:
    long AccNo;
    double balance;
    void DepositeMoney();
    public:
    getAccountNo() { return AccNo;}
    }

    void main()
    {Account Ac.DepositeMoney(10000000000); } //INVALID DepositeMoney is INACCESSIBLE

    Inheritance:
    One should give all Examples for each type of Inheritance i.e. Single, Multiple, Hierarchical & Hybrid.
    Here is an example of MULTIPLE Inheritance:
    class NeworkDevice
    {
    int SSID;
    };

    class USBDevice
    {
    int ID;
    };

    class WirelessDevice: public NetworkDevice, public USBDevice
    {};

    POLYMORPHISM:
    1.Function Overloading : int area(int) | int area(double)
    2. Operator Overloading : Complex operator+(Operator);
    3.Function Overriding : A derived class will have a method with same name as that of Base but different Prototype.

    Please Do not give Dummy answers if you cannot. Hope you liked it. Thanks.



    Posted by: Annoying_Orange    

    Contact Annoying_Orange Contact Annoying_Orange

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    What is partial class. & what is advantage.
    View Answer
    What is the name of c#.net compiler?
    View Answer
    What is an object?Define a class.
    View Answer
    Define abstraction,encapsulation,inheritance:with example.
    View Answer
    Define abstraction,encapsulation,inheritance:with example.
    View Answer
    What is mean "Death of Diamod"?
    View Answer
    what is the main difference between delegate and an event in c#?
    View Answer
    How to use HASH TABLE,ARRAYLIST in c# explain with example?
    View Answer
    Assemblies are of the following types:

    View Answer
    What is the difference between shadow and override

    View Answer
    What is the top .NET class that everything is derived from?

    View Answer
    C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL C# Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0 Seconds