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

Write a program in java to establish a connection between client and server?

1016


Difference between arraylist and vector.

1180


What is logical variable?

1040


What are access specifiers in java ?

1200


What is difference between public static and void?

1074


How do you get the length of a string in java?

1056


Mention some interfaces implemented by linked list in java.

1078


Can we declare an array without size in java?

1061


What is the association?

1025


What do you mean by boolean?

1113


Differences between C and Java?

1283


What is java string pool?

1057


What is the difference between sleep and wait in java?

1010


What are java packages? What's the significance of packages?

1405


How will you add panel to a frame?

1163