Inheritance used in Java

Java Object Oriented Programming Concepts, Java Inheritance Types of Inheritance, Java Polymorphism, Method OverLoading, Method Overriding, Java Abstraction, Java Interfaces and Java Encapsulation.
Post Reply
swathi
Posts: 134
Joined: Fri Nov 23, 2018 2:52 am

Inheritance used in Java

Post by swathi » Sat Dec 08, 2018 6:46 am

Why is Inheritance used in Java?

ramya
Posts: 89
Joined: Fri Nov 23, 2018 2:55 am

Re: Inheritance used in Java

Post by ramya » Sat Dec 08, 2018 6:48 am

There are various advantages of using inheritance in Java that is given below.

1) Inheritance provides code reusability. The derived class does not need to redefine the method of base class unless it needs to provide the specific implementation of the method.

2) Runtime polymorphism cannot be achieved without using inheritance.

3) We can simulate the inheritance of classes with the real-time objects which makes OOPs more realistic.

4) Inheritance provides data hiding. The base class can hide some data from the derived class by making it private.

5) Method overriding cannot be achieved without inheritance. By method overriding, we can give a specific implementation of some basic method contained by the base class.

kadammanali987
Posts: 4
Joined: Thu Dec 13, 2018 3:54 am

Re: Inheritance used in Java

Post by kadammanali987 » Mon Dec 31, 2018 4:56 am

Java is an Object Oriented Programming Language. Inheritance is one of the most popular concept in Object Oriented Programming.

We use Inheritance in Java for following reasons:

Encapsulation: If we have some common attributes, then we encapsulate these in a parent class and just give specific attributes to child classes.
Polymorphism: We can also use Polymorphism with Inheritance in Java. So that based on the type of Child class, same class behaves differently.
Code Reusability: Using Inheritance helps in reusing code.
Efficiency: It is efficient to use Inheritance while writing code. This can increase the speed of project.

sekhar
Posts: 47
Joined: Mon Dec 31, 2018 6:40 am

Re: Inheritance used in Java

Post by sekhar » Tue Jan 22, 2019 10:40 am

Java is an Object Oriented Programming Language. Inheritance is one of the most popular concept in Object Oriented Programming.

We use Inheritance in Java for following reasons:

Encapsulation: If we have some common attributes, then we encapsulate these in a parent class and just give specific attributes to child classes.
Polymorphism: We can also use Polymorphism with Inheritance in Java. So that based on the type of Child class, same class behaves differently.
Code Reusability: Using Inheritance helps in reusing code.
Efficiency: It is efficient to use Inheritance while writing code. This can increase the speed of project.

Post Reply

Return to “Java Object Oriented Programming”