Professional Documents
Culture Documents
Assignment 3
Assignment 3
1 Practical significance
Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object. It is an important part of OOPs
(Object Oriented programming system)
The idea behind inheritance in Java is that you can create new classes
that are built upon existing classes. When you inherit from an existing class,
you can reuse methods and fields of the parent class. Moreover, you can add
new methods and fields in your current class also.
2 Competency
“Apply the basic knowledge of inheritance in solving engineering problems”.
3 Experimental Outcomes
The most important use of inheritance in Java is code re usability. The code
that is present in the parent class can be directly used by the child class.
Method overriding is also known as runtime polymorphic. Hence, we can
achieve Polymorphic in Java with the help of inheritance
1
4 Theoretical Background:
Inheritance represents the IS-A relationship which is also known as a parent-
child relationship.
Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object. It is an important part of OOPs
(Object Oriented programming system)
The idea behind inheritance in Java is that you can create new classes
that are built upon existing classes. When you inherit from an existing class,
you can reuse methods and fields of the parent class. Moreover, you can add
new methods and fields in your current class also.
2
2 Multiple inheritance
3 Hierarchical inheritance
4 hybrid inheritance
OUTPUT:
Programmer salary is:40000.0
Bonus of programmer is:10000
6 Precautions
To prevent inheritance, use the keyword ”final” when creating the class.
The designers of the String class realized that it was not a candidate for
inheritance and have prevented it from being extended
7 Procedure
The implementation of its parent class recreates a new class, which is the child
class. To inherit the parent class, a child class must include a keyword called
”extends.” The keyword ”extends” enables the compiler to understand that
the child class derives the functionalities and members of its parent class.
3
8 Observations
The idea behind inheritance in Java is that you can create new classes that
are built upon existing classes. When you inherit from an existing class, you
can reuse methods and fields of the parent class. Moreover, you can add new
methods and fields in your current class also.
9 Conclusions
Conclusion. It is a property by which another class acquires a class’s prop-
erties and behavior to provide the reusability of code. There are different
types of inheritance in Java, such as Single Inheritance, Multi-level Inheri-
tance, Hierarchical Inheritance, and Multiple Inheritance in Java.