ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Inheritance in Java

Essay by   •  December 7, 2010  •  Essay  •  389 Words (2 Pages)  •  1,361 Views

Essay Preview: Inheritance in Java

Report this essay
Page 1 of 2

In Java programming, inheritance plays an important role in a programmer's ability to reuse codes. Inheritance in basic terms allows a subclass to use the variables and methods of a superclass. When a programmer creates a subclass with new variables and methods, it can easily use the superclass's methods and variables by extending without having to rewrite the entire superclass over again. Therefore, the subclass inherits variables and methods from the superclass. In this sense, inheritance helps save time in writing codes because imagine how time-consuming it would be to work with a superclass which had thousands of methods and variables. Needless to say, the time spent by the programming would be very costly if inheritance was not available.

Not only does inheritance saves programming time, it helps maintain efficiency and accuracy. If a programmer did not have the ability to use inheritance, they would have to rewrite the classes to add variables or methods and would increase the chances of creating errors. With thousands of variables and methods in a program, it can be easy to lose track or be inconsistent when editing changes.

An example used by Richard Baldwin helps illustrate how inheritance works. A superclass RADIO has attributes and methods of components of a car radio. When a new class is created to add tape player, the subclass COMBO, will inherit certain attributes from the superclass RADIO when using the new methods to create a function. For instance, Baldwin added a new method called playTape in the program and extends to the superclass RADIO to pull specific methods to determine whether or not the tape is in or out before playing the radio. Knowing whether or not the radio is turned on is a method in the superclass RADIO and does not need to be written again in the subclass COMBO. The use of inheritance in this case is important because the subclass COMBO can basically retrieve methods in the superclass RADIO by easily extending to it.

In conclusion, inheritance is a very powerful tool in Java programming because it has the ability to derive one class to another. In an Object Oriented program such as Java, the use of inheritance has become favorable amongst programmers to a large degree.

...

...

Download as:   txt (2.2 Kb)   pdf (52.7 Kb)   docx (9.3 Kb)  
Continue for 1 more page »
Only available on ReviewEssays.com
Citation Generator

(2010, 12). Inheritance in Java. ReviewEssays.com. Retrieved 12, 2010, from https://www.reviewessays.com/essay/Inheritance-in-Java/19565.html

"Inheritance in Java" ReviewEssays.com. 12 2010. 2010. 12 2010 <https://www.reviewessays.com/essay/Inheritance-in-Java/19565.html>.

"Inheritance in Java." ReviewEssays.com. ReviewEssays.com, 12 2010. Web. 12 2010. <https://www.reviewessays.com/essay/Inheritance-in-Java/19565.html>.

"Inheritance in Java." ReviewEssays.com. 12, 2010. Accessed 12, 2010. https://www.reviewessays.com/essay/Inheritance-in-Java/19565.html.