Question :

What is Inheritance in Java? Explain.

Subject

Programming in Java

Standard

Computer Science Engineering

Views

1450

Asked By

Krishav

Qayanat
Answer / Solution

The Inheritance in Java basics is

  • The process by which one class acquires the properties(data members) and functionalities(methods) of another class is called inheritance. The aim of inheritance is to provide the reusability of code so that a class has to write only the unique features and rest of the common properties and functionalities can be extended from the another class.
  • Inheritance is a process of defining a new class based on an existing class by extending its common data members and methods.
  • Inheritance allows us to reuse of code, it improves reusability in your java application.
  • The biggest advantage of Inheritance is that the code that is already present in base class need not be rewritten in the child class.    

Inheritance is used in java : 

  • For Method Overriding (so runtime polymorphism can be achieved).
  • For Code Reusability.

Terms used in Inheritance

  • Class: 
    • A class is a group of objects which have common properties. It is a template or blueprint from which objects are created.
  • Sub Class/Child Class: 
    • Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class.
  • Super Class/Parent Class: 
    • ​​​​​​​Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class.
  • Reusability: 
    • As the name specifies, reusability is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.

Top Trending Questions


Recent Question Update

What is the syntax of Java Inheritance? Explain with example.
Explain various Access Modifiers in Java

Advantages Of NCERT, CBSE & State Boards Solutions For All Subjects

  • All the NCERT Solutions have been prepared by academic experts having 10+ years of teaching experience.
  • They have prepared all the solutions in simple and easy language so that each and every student can understand the concepts easily.
  • All the solutions have been explained step to step-wise in details with better explanations.
  • Students can also use these question and answers for your assignments and in homework help.
  • All the solutions have been explained in detail and the answers have been compiled in a step-wise manner.
  • All the questions and answers are commonly prepared according to the Latest Syllabus of Board Education and Guidelines.
  • Students can know about the various types of questions asked in the exams with the help of these solutions.

Top Course Categories