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 / pari

Minimize the amount of duplicate code in an application

If duplicate code (variable and methods) exists in two related classes, we can refactored that hierarchy by moving that common code up to the common superclass.

Better organization of code

Moving of common code to superclass results in better organization of code.

Code more flexible change

Inheritance can also make application code more flexible to change because classes that inherit from a common superclass can be used interchangeably. If the return type of a method is superclass.

Where to use inheritance:

Before using inheritance first compare the relationship for the two classes. Use inheritance only if there is a parent child relationship is there.
A way to test the relationship is to ask a "is-a" question.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a abstract class be declared final?

952


What is a functional interface?

977


What is the role of garbage collector in java?

911


Can you extend singleton class?

1043


Can I uninstall java?

990


What are the important features of Java 10 release?

960


how to create daemon thread in java?

1016


What is a method header?

978


How to declare an arraylist in java?

1016


What is final access modifier in java?

1080


How do you sort arraylist in descending order?

987


What is a constructor overloading in java?

992


Which oo concept is achieved by using overloading and overriding?

961


How can you read content from file in java?

969


Which class is the superclass for all the classes?

985