Write a program of your own choice in which you can explain encapsulation and inheritance concepts, and in the context of that program write your
answer below that will explain
1. How encapsulation and inheritance was achieved in this program?
2. What are the benefits you get after implementing encapsulation and inheritance in this program?
3. What are the disadvantages if you will not use encapsulation and inheritance in this program?
Note: the program must be in java any IDE or netbeans and paste in comment the implementation!
Answers
Answered by
0
Answer:
1.Inheritance dictates that a child class (subclass) inherits all the attributes and methods from a parent class (superclass). Encapsulation dictates that one class must not have access to the (private) data of another class
2 inheritance are code reusability and readability. When child class inherits the properties and functionality of parent class, we need not to write the same code again in child class. This makes it easier to reuse the code, makes us write the less code and the code becomes much more readable..
3.Main disadvantage of using inheritance is that the two classes (base and inherited class) get tightly coupled. This means one cannot be used independent of each other.
Explanation:
Similar questions