Inheritance in java at tcci, ahmedabad

Page 1

Inheritance In Java At TCCI, Ahmedabad What is Inheritance Its mechanism of building new class from existing class.

why Inheritance is used in programming? Inheritance is used to reuse code of existing/old class in new class.In this way we can increase time and space efficiency. Existing/Old class is called parent class,New class is called child class. Existing class<---------------------------------->Parent/Super/Base class New class<--------------------------------------->Child/Sub/Derived class Here, no. of parent class and child class can vary, according to this no. of class there are types of inheritance.

Types of Inheritance Single Inheritance One parent class and one child class A------------------------>B Multilevel Inheritance One parent class and one child class,again new class derived from that child class A------------------>B------------------->C Multiple Inheritance More than one parent class and one child class A------------------>C, B------------------->C Hierarchical Inheritance Parent class inherited to more than one child class A------------------>B,A------------------->C

Derived class can do following : • •

Inherite all members of base class expect its constructor. Access all public & protected members of the base class

Define its own private member


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Inheritance in java at tcci, ahmedabad by Rosario Riley - Issuu