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...

Advantages of Inheritance in java.

Answer Posted / josh

Inheritance can lead to a combinatorial explosion of
classes. Composition should be somewhere in the code
oftentimes. For example, an Employee object can "contain" a
PaymentType object, a PaymentSchedule object, and a
PaymentMethod object. Each of those 3 objects are their own
classes. The Employee class creates instance of those
classes and "holds" on to them. From there, a higher class
such as a PayrollSystem can look at an Employee object and
query that Employee about that Employee's information
(namely its object contents). With composition, your code is
highly decoupled, meaning that those 3 object held by
Employee can easily be held by some other class (hence code
reuse). It is important to note that PaymentSchedule,
PaymentMethod, and PaymentType should be interfaces which
have multiple concrete implementations to them (ie. a
PaymentType interface could be implemented with an Hourly,
Salary, or SalaryWithCommission class for a given Employee).
Inheritance causes high coupling and reduces code
reusability. It helps to write a UML static(class) diagram
before typing up code

Is This Answer Correct ?    10 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does ide stand for?

877


When is the finally clause of a try-catch-finally statement executed?

971


Why string is not thread safe?

960


How to find the given number is a prime number or not by getting input from the user

1026


What is the program compilation process?

1030


What are the benefits of operations in java?

939


Why hashcode is used in java?

917


Write a program to find the whether a number is an Armstrong number or not?

953


Can we override the static method?

962


Explain about data types?

999


How to create com object in Java?

1008


How will you invoke any external process in java?

1045


What is java algorithm?

879


What is javac_g?

967


what is the major difference between linkedlist and arraylist in java?

1095