Java Programming Inheritance is an important concept in object oriented programm
ID: 3773834 • Letter: J
Question
Java Programming
Inheritance is an important concept in object oriented programming. It allows one class to acquire and extend all the behaviors and attribute of another class. In this context,
What is the significance of the concept of inheritance within the concept of object oriented programming?
Provide a programming problem in which inheritance should be used (You do not need to write codes for this discussion. Instead, describe the programming problem and explain why inheritance should be used).
Research the concept of Polymorphism and, again, provide a programming problem in which polymorphism should be used.
Explanation / Answer
Inheritance:
Manly this is for re-usable of class members, It supports the concept of hierarchical classification.
For example: Car is a classification of Four Wheeler. Here Car acquires the properties of a four-wheeler. Other classifications could be a jeep, tempo, van etc. Four Wheeler defines a class of vehicles that have four wheels, and specific range of engine power, load carrying capacity etc. Car (termed as a sub-class) acquires these properties from Four Wheeler (termed as a super-class), and has some specific properties, which are different from other classifications of Four Wheeler, such as luxury, comfort, shape, size, usage etc.
A car can have further classification such as an open car, small car, big car etc, which will acquire the properties from both Four Wheeler and Car, but will still have some specific properties. This way the level of hierarchy can be extended to any level.
Java Swing and Awt classes represent best examples for inheritance.
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.