What is meant by inheritance ? Explain with an example

Showing Answers 1 - 4 of 4 Answers

swapna

  • Sep 28th, 2005
 

inheritance is an OOPS concept by which a class can acquire the characteristics of another class.

The class from which its inheriting is called base class  and the class which is inheriting is called sub class.

class demo1

{

}

class demo2 extends demo1

{

}

Amit

  • Aug 18th, 2011
 

Inheritance is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications. Using inheritance, you can create a general class that defines traits common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique to
it. In the terminology of Java, a class that is inherited is called a superclass.

The class that does the inheriting is called a subclass. Therefore, a subclass is a specialized version of a
superclass. It inherits all of the instance variables and methods defined by the superclass and adds its own, unique elements.

Code
  1. /* Single Inhetitance To Find Area Of Rectangle */"The Area of rectangle of length "

  2. +Rect.length+" and breadth "+Rect.breadth+" is "+Rect.a);

  3. }

  4. }

  Was this answer useful?  Yes

Inheritance is acquiring properties of one class from another class, the class which is inherited is called base class and the class which acquir the properties is called derived class.
eg:

Code
  1. span style="font-style: italic;">//base class

  2. //derived class

  3. {

  4. }

  Was this answer useful?  Yes

Shahnoor Alam

  • Aug 28th, 2017
 

Inheritance is an OOPS concept by which a class can acquire the characteristics of another class. The class that does the inheriting is called a subclass. Therefore, a subclass is a specialized version of a superclass.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions