Question

Demonstrate through code and explanation each of the following object oriented concepts: Inheritance Encapsulation Polymorphism Discuss...

Demonstrate through code and explanation each of the following object oriented concepts: Inheritance Encapsulation Polymorphism Discuss the advantages of applying object orienting coding principles.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Inheritence: Inheritence, encapsulation and polymorphism are three pillars of object oriented programming.

Inheritence: Inheritence is a feature of the OOPS language in which Sub class inherit the properties of the Super class.

By using extends keyword we can implement is-a relationship. The main advantage of is a relationship is reusabillity of te code.

Whatever the parrent class has by default available to the child hence child class refrences can cal both parrent and child class method.

What ever the child has bydefault not available to the parrent hence on the parrent class reference we can call only parrents calss method and we cant call chld specific methods.

There are different type of inheritence which are follows:

i) single inheritence

ii) multilevel inheritence

iii) Multiple Inheritence

iv) Hybrid Inheritence

Polymorphism:

we can use same name to represent multiple forms in polymorphism. The example of polymorphism is overloading and overriding.

In real life example, I am giving real life example which is slightly funny, A boy uses the word FRIENDSHIP to starts LOVE, but girl uses the same word to ends same word but different attitudes.

This behaviour is nothing but polymorphim.

Encapsulation:

In object oriented programming languages, encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination thereof: A language mechanism for restricting direct access to some of the object's components.

A class is said to be tightly encapsulated iff every data member declared as the private.

whether those methods declared as public or not required to check.

Add a comment
Know the answer?
Add Answer to:
Demonstrate through code and explanation each of the following object oriented concepts: Inheritance Encapsulation Polymorphism Discuss...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT