0% found this document useful (0 votes)
10 views10 pages

Inheritance in Java by Deepak Smart Programming Lyst4552

The document provides an overview of inheritance in Java, detailing the relationships between classes, including IS-A, HAS-A, and USES-A relationships. It outlines the types of inheritance such as single, multilevel, hierarchical, multiple, and hybrid, while also discussing the syntax and key points regarding inheritance. Additionally, it includes potential interview questions related to the topic and company contact information for Smart Programming in Mohali, Chandigarh, India.

Uploaded by

monikasatnami73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

Inheritance in Java by Deepak Smart Programming Lyst4552

The document provides an overview of inheritance in Java, detailing the relationships between classes, including IS-A, HAS-A, and USES-A relationships. It outlines the types of inheritance such as single, multilevel, hierarchical, multiple, and hybrid, while also discussing the syntax and key points regarding inheritance. Additionally, it includes potential interview questions related to the topic and company contact information for Smart Programming in Mohali, Chandigarh, India.

Uploaded by

monikasatnami73
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Smart Programming : Channel

An investment in Knowledge pays the best interest….

Inheritance in Java
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Relationship Between Java Classes :-


=> Use of relationship between java classes :-
1. Code Reusability
2. Less Execution Time
3. Less Memory Usage

=> Types of relationships :-


1. IS-A Relationship (Inheritance)
-> IS-A relationship is one in which data
members of one class is obtained into another class
through the concept of inheritance
-> Types of IS-A relationship :-
1.1 Single Inheritance
1.2 Multilevel Inheritance
1.3 Hierarchical Inheritance
1.4 Multiple Inheritance
1.5 Hybrid Inheritance
1
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

2. HAS-A Relationship (Association)


-> HAS-A relationship is one in which an
object of one class is created as a data member into
another class.
-> Types of HAS-A relationship :-
2.1 Aggregation
2.2 Composition
3. USES-A Relationship (Dependence)
-> USES-A relationship is one in which a
method of one class is using an object of another
class

2
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> UML Notation in Java :-

3
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> Terms used for inheritance :-


1. Class
2. Sub-Class / Child Class
3. Super-Class / Parent Class
4. Reusability

=> IS-A Relationship :-


-> It is also known as "Inheritance"
-> IS-A Relationship or Inheritance is achieved
by using "extends" keyword
-> All java classes except Object class will
always have one parent class thus we can say that
the total java API is implemented based on
inheritance concept

4
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> Use of inheritance :-


1. Code Reusability
2. For Method Overriding to achieve runtime
polymorphism

=> Syntax of inheritance :-


class Sub-Class extends Super-Class
{
//body
}

=> Types of Inheritance :-


-> Total there are 5 types of inheritance :-
1. Single Inheritance
2. Multilevel Inheritance
3. Hierarchical Inheritance

5
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

4. Multiple Inheritance
5. Hybrid Inheritance

=> Points to Remember :-


-> Default Parent Class :- By default if any java
class does not inherit any parent class then it
inherits Object class

6
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

-> Parent class can only be one :- There can be


only one parent class for every class and due to this
java does not support multiple inheritance
-> Which part is not inherited :-
1. Private members of parent class is not
inherited in child class
2. Constructors are not inherited because
constructors are not the part of class members
(class members are only fields, methods, nested
classes)
-> Cyclic inheritance is not possible
1. class A extends A
2. class A extends B { - }
class B extends A { - }
-> Multiple and Hybrid inheritance is not possible
in case of classes but it is possible in case of
interfaces

7
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Interview Questions :-
1. Why java does not support multiple inheritance
2. How we can achieve Multiple and Hybrid
inheritance
3. Various possible combinations for inheritance

8
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Company Links & Contacts

Company Name: Smart Programming (+91 62838-30308)

Address : Chandigarh & Mohali (Punjab), India

Websites: https://www.smartprogramming.in/
https://courses.smartprogramming.in

Android App:
https://play.google.com/store/apps/details?id=com.sma
rtprogramming

YouTube Channel:
https://www.youtube.com/c/SmartProgramming

You might also like