Top Answer
User Avatar
Wiki User
Answered 2009-05-16 12:26:14

Inheritance is an object oriented feature supported by Java wherein the features of one Java class can be inherited/made available in another class. This creates a parent child relationship between these 2 classes. Class Inheritance in java mechanism is used to build new classes from existing classes. The inheritance relationship is transitive: if class x extends class y, then a class z, which extends class x, will also inherit from class y. Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.


public class Parent {

private String name = "Rocky";

public String getName(){




public class Child extends Parent {

public static void main(String[] args){

System.out.println("Name in Parent is: " + getName());



Here the getName() method is available only in the parent class but is directly used in the child class because the method is public and is directly accessible to the child class since it has extended the parent class.

Benefits of Inheritance:

One of the key benefits of inheritance is to minimise the amount of duplicate code in an application by sharing common code amongst several subclasses. Where equivalent code exists in two related classes, the hierarchy can usually be refactored to move the common code up to a mutual superclass. This also tends to result in a better organisation of code and smaller, simpler compilation units.

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

User Avatar

Your Answer


Still have questions?

Related Questions

What are the features of object oriented programming?

The features of object oriented programming are Abstraction, Encapsulation, Polymorphism & Inheritance

What is an essential of Object Oriented Programming?

The 3 essential concepts of Object Oriented Programming are:InheritanceEncapsulation &Polymorphism

How do you create multiple inheritance in c?

You don't. Inheritance is a feature of object oriented programming languages. C is not object oriented.

What is Object Oriented Programming Approach?

An object oriented programming approach is one in which we use the various object oriented concepts like inheritance, polymorphism, encapsulation, abstraction etc.

What are the defining traits of an object oriented language?

Object oriented programming languages must support the four fundamentals of object-oriented programming: encapsulation, abstraction, inheritance and polymorphism.

Why java is called object oriented programming?

Java is called an object oriented programming language because it implements many of the object oriented programming concepts like abstraction, encapsulation, inheritance etc.

Is it java pure object oriented programming language?

No, Java is a object oriented programming not a pure object oriented programming Bcoz java does not support multiple is object oriented programming bcoz its implement the basic object oriented concepts like inheritace,polimophism, abstraction etc except multiple inheritance.For any query or suggestion plz mail

Explain different types of inheritance of object oriented programming?

== ==

What are the characteristic of Object Oriented programming?

Object oriented programming contains three characterestics they are 1. Encapsulation 2. Polymorphism 3. Inheritance

What is the distinct difference between object oriented concept and object oriented programming?

Object oriented concepts are a generalisation of the object oriented principals (encapsulation, inheritance, polymorphism and abstraction) without specifying a particular implementation of those principals. Object oriented programming is the application of those principals through an object oriented programming language.

Why is inheritance a key feature of object oriented programming?

Inheritance is a key feature of object oriented programming because:It promotes code reuseIt avoids code redundancyJava allows us to use Inheritance extensively in our programs.

3 pillars of object oriented programming?

Encapsulation, Polymorphism, and Inheritance.

Major features of object oriented programming?

Some of the major features of object oriented programming are:InheritancePolymorphismEncapsulationData hidingAbstractionetc.

What are the three characteristics of object-oriented programming?

Encapsulation, Inheritance, and Polymorphism

What are Four principles of object oriented programming?

Inheritance, Abstraction, Polymorphism & Encapsulation.

What are the characteristics of object-oriented programming?

Encapsulation, inheritance, polymorphism and abstraction.

What three concepts are the basis for object oriented programming?

encapsulation,polymarphisam and inheritance

What are the four characteristics of Object Oriented programming?

The four pillars of Object Oriented Programming are:EncapsulationInheritancePolymorphismAbstrractionThese programs are meant to just talk about the object. They do not allow for any abstracts to be present.

Why is Java called an Object Oriented Programming Language?

Because it implements object oriented programming concepts like inheritance, polymorphism, encapsulation, abstraction, polymorphism etc etc.

Difference between Object oriented programming and java?

JAVA is an Object Based Programming Language. it doesn't provide multiple inheritance and operator overloading. while Object Oriented Lanuages provides both.

What are the various elements of Object oriented programming?

Encapsulation, data hiding, inheritance and polymorphism.

What are the basic concept of object oriented programming language?

Inheritance Encapsulation Polymorphism Abstraction

What are the unique advantages of an object oriented programming paradigm?

Encapsulation, inheritance, polymorphism and abstraction.

Is encapsulation a characteristic of procedural or object oriented programming?

Encapsulation is one of the four pillars of object-oriented programming. The other three are inheritance, polymorphism and abstraction.

Why is Java called OOP Language?

Java is called Object Oriented Programming Language because in Java, you can implement all the Object Oriented methodologies (inheritance, multi-inheritance, polymorphism, encapsulation) and Programing paradigm in Java is also Object Oriented.