SlideShare a Scribd company logo
1 of 15
Java Inheritance
There are two ways to reuse the existing classes
Composition
define a new class, which is composed of existing classes.
Composition exhibits a "has-a" relationship.
Inheritance
derive a new class based on an existing class
with modifications / extensions.
Inheritance exhibits a “is-a" relationship.
2
Inheritance: Definition
 inheritance: a parent-child relationship between classes
 Reuse of existing code or Method Overriding (Runtime Polymorphism).
 allows sharing of the behavior of the parent class into its child classes
 child class can add new behavior / override existing behavior from parent
 The more general class is called:
 superclass, base class, parent class
 The more specific class is called:
 subclass, derived class, child class
3
 Two kinds:
 implementation: the code that defines methods.
 Derived class inherits the implementations of all methods
from base class.
 interface: the method prototypes only.
 Accessing superclass methods from derived class.
 Can use super() to access all (non-private) superclass methods.
 Can use super() to call base class constructor.
Syntax of Inheritance:
class Subclass-name extends Superclass-name
{
//methods and fields
}
keyword extends:
Indicates that you are making a new class that derives from an existing class.
Types of Inheritance:
On the basis of class, there can be three types of inheritance:
Single Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Multiple & Hybrid - supported through interface only
Why multiple inheritance is not supported in java?
class A
{
void msg(){System.out.println("Hello");}
}
class B
{
void msg(){System.out.println("Welcome");}
}
class C extends A,B
{ //suppose if it were
Public Static void main(String args[]){
C obj=new C();
obj.msg(); //Now which msg() method would be invoked?
}
}
super keyword
The super is a reference variable that is used to refer immediate
parent class object.
Usage of super Keyword
super is used to refer immediate parent class instance variable.
super() is used to invoke immediate parent class constructor.
super is used to invoke immediate parent class method.
Example:
class Vehicle
{
int speed=50;
}
class Bike extends Vehicle
{
int speed=100;
void display()
{
System.out.println(speed);
//will print speed of Bike
}
public static void main(String args[])
{
Bike b=new Bike();
b.display();
}
}
class Vehicle
{
int speed=50;
}
class Bike extends Vehicle
{
int speed=100;
void display()
{
System.out.println(super.speed);
//will print speed of Vehicle now
}
public static void main(String args[])
{
Bike b=new Bike();
b.display();
}
}
super is used to invoke parent class constructor.
class Vehicle
{
Vehicle()
{
System.out.println("Vehicle is created");
}}
class Bike extends Vehicle
{
Bike()
{
super();//will invoke parent class constructor
System.out.println("Bike is created");
}
public static void main(String args[])
{
Bike b=new Bike();
}}
super can be used to invoke parent class method.
class Person
{
void message(){System.out.println("welcome");}
}
class Student extends Person
{
void message() { System.out.println("welcome to java");
}
void display()
{
message();//will invoke current class message() method
super.message();//will invoke parent class message() method
}
public static void main(String args[])
{
Student s=new Student();
s.display();}}
Method Overriding in Java
Having the same method in the subclass as declared in the parent
class is known as method overriding.
In other words, If subclass provides the specific implementation of
the method i.e. already provided by its parent class, it is known as
Method Overriding.
Method Overriding is used for Runtime Polymorphism
Rules for Method Overriding:
method must have same name as in the parent class
method must have same parameter as in the parent class.
must be inheritance (IS-A) relationship.
class Vehicle
{
void run()
{
System.out.println("Vehicle");
}
}
class Bike extends Vehicle
{
public static void main(String args[])
{
Bike obj = new Bike();
obj.run();
}
}
class Vehicle
{
void run()
{
System.out.println("Vehicle is running");
}
}
class Bike extends Vehicle
{
void run()
{
System.out.println("Bike is running");
}
public static void main(String args[])
{
Bike obj = new Bike();
obj.run();
}
Method Overloading Method Overriding
1) Method overloading is used to
increase the readability of the program.
Method overriding is used to provide
the specific implementation of the
method that is already provided by its
super class.
2) method overloading is performed
within a class.
Method overriding occurs in two
classes that have IS-A relationship.
3) In case of method overloading
parameter must be different.
In case of method overriding parameter
must be same.

More Related Content

What's hot

Polymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarPolymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarAnimesh Sarkar
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oopsHirra Sultan
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPTPooja Jaiswal
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singhdheeraj_cse
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdmHarshal Misalkar
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java yash jain
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Paumil Patel
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Gajendra Singh Thakur
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Sujan Mia
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance pptNivegeetha
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingBurhan Ahmed
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In JavaCharthaGaglani
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In JavaManish Sahu
 
Inheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaMananPasricha
 

What's hot (20)

Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Polymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarPolymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh Sarkar
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Inheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan PasrichaInheritance in c++ by Manan Pasricha
Inheritance in c++ by Manan Pasricha
 
Java interface
Java interfaceJava interface
Java interface
 

Viewers also liked

Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesJon Kruger
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsRicardo Wilkins
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Isuru Perera
 
Lesson 1 • Elements & Principles of Design and Art
Lesson 1 • Elements & Principles of Design and ArtLesson 1 • Elements & Principles of Design and Art
Lesson 1 • Elements & Principles of Design and ArtMarcio Sargento
 
Iot data aggrigation
Iot data aggrigationIot data aggrigation
Iot data aggrigationdokechin
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...cprogrammings
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design PrinciplesSerhiy Oplakanets
 
Scanner
ScannerScanner
Scannerat1211
 
Hierarchical Object Oriented Design
Hierarchical Object Oriented DesignHierarchical Object Oriented Design
Hierarchical Object Oriented Designsahibsahib
 

Viewers also liked (18)

Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID Principles
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
Unified Modeling Language (UML), Object-Oriented Programming Concepts & Desig...
 
Lesson 1 • Elements & Principles of Design and Art
Lesson 1 • Elements & Principles of Design and ArtLesson 1 • Elements & Principles of Design and Art
Lesson 1 • Elements & Principles of Design and Art
 
Iot data aggrigation
Iot data aggrigationIot data aggrigation
Iot data aggrigation
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles
 
Scanner
ScannerScanner
Scanner
 
Hierarchical Object Oriented Design
Hierarchical Object Oriented DesignHierarchical Object Oriented Design
Hierarchical Object Oriented Design
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 

Similar to Java Inheritance: Understanding Inheritance and Method Overriding

Inheritance Slides
Inheritance SlidesInheritance Slides
Inheritance SlidesAhsan Raja
 
INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING ManpreetSingh1387
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in javaAtul Sehdev
 
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxSodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxRudranilDas11
 
Unit No 3 Inheritance annd Polymorphism.pptx
Unit No 3 Inheritance annd Polymorphism.pptxUnit No 3 Inheritance annd Polymorphism.pptx
Unit No 3 Inheritance annd Polymorphism.pptxDrYogeshDeshmukh1
 
Lecture 6 inheritance
Lecture   6 inheritanceLecture   6 inheritance
Lecture 6 inheritancemanish kumar
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritanceKalai Selvi
 
Inheritance chepter 7
Inheritance chepter 7Inheritance chepter 7
Inheritance chepter 7kamal kotecha
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Designİbrahim Kürce
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interfaceShubham Sharma
 
polymorphism method overloading and overriding .pptx
polymorphism method overloading  and overriding .pptxpolymorphism method overloading  and overriding .pptx
polymorphism method overloading and overriding .pptxthamaraiselvangts441
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3RatnaJava
 

Similar to Java Inheritance: Understanding Inheritance and Method Overriding (20)

Inheritance Slides
Inheritance SlidesInheritance Slides
Inheritance Slides
 
Java
JavaJava
Java
 
Chap-3 Inheritance.pptx
Chap-3 Inheritance.pptxChap-3 Inheritance.pptx
Chap-3 Inheritance.pptx
 
Inheritance1
Inheritance1Inheritance1
Inheritance1
 
INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING INHERTANCE , NARROW AND WIDENING
INHERTANCE , NARROW AND WIDENING
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
 
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxSodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
 
Unit No 3 Inheritance annd Polymorphism.pptx
Unit No 3 Inheritance annd Polymorphism.pptxUnit No 3 Inheritance annd Polymorphism.pptx
Unit No 3 Inheritance annd Polymorphism.pptx
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Lecture 6 inheritance
Lecture   6 inheritanceLecture   6 inheritance
Lecture 6 inheritance
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Inheritance chepter 7
Inheritance chepter 7Inheritance chepter 7
Inheritance chepter 7
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
 
inheritance.pptx
inheritance.pptxinheritance.pptx
inheritance.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
Core java day5
Core java day5Core java day5
Core java day5
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
 
polymorphism method overloading and overriding .pptx
polymorphism method overloading  and overriding .pptxpolymorphism method overloading  and overriding .pptx
polymorphism method overloading and overriding .pptx
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3
 

More from BHUVIJAYAVELU

Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...
Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...
Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...BHUVIJAYAVELU
 
Java exception handling
Java exception handlingJava exception handling
Java exception handlingBHUVIJAYAVELU
 
Flow control and error control
Flow control and error controlFlow control and error control
Flow control and error controlBHUVIJAYAVELU
 
3 2--power-aware-cloud
3 2--power-aware-cloud3 2--power-aware-cloud
3 2--power-aware-cloudBHUVIJAYAVELU
 

More from BHUVIJAYAVELU (8)

Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...
Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...
Eprojectprojectfinalreportgsmmonitoringcontrollingofdevicesusinggsm 090811012...
 
Lecture no1
Lecture no1Lecture no1
Lecture no1
 
Java arrays
Java arraysJava arrays
Java arrays
 
Hybrid m-a-t
Hybrid m-a-tHybrid m-a-t
Hybrid m-a-t
 
Java packages
Java packagesJava packages
Java packages
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Flow control and error control
Flow control and error controlFlow control and error control
Flow control and error control
 
3 2--power-aware-cloud
3 2--power-aware-cloud3 2--power-aware-cloud
3 2--power-aware-cloud
 

Java Inheritance: Understanding Inheritance and Method Overriding

  • 1. Java Inheritance There are two ways to reuse the existing classes Composition define a new class, which is composed of existing classes. Composition exhibits a "has-a" relationship. Inheritance derive a new class based on an existing class with modifications / extensions. Inheritance exhibits a “is-a" relationship.
  • 2. 2 Inheritance: Definition  inheritance: a parent-child relationship between classes  Reuse of existing code or Method Overriding (Runtime Polymorphism).  allows sharing of the behavior of the parent class into its child classes  child class can add new behavior / override existing behavior from parent  The more general class is called:  superclass, base class, parent class  The more specific class is called:  subclass, derived class, child class
  • 3. 3  Two kinds:  implementation: the code that defines methods.  Derived class inherits the implementations of all methods from base class.  interface: the method prototypes only.  Accessing superclass methods from derived class.  Can use super() to access all (non-private) superclass methods.  Can use super() to call base class constructor.
  • 4. Syntax of Inheritance: class Subclass-name extends Superclass-name { //methods and fields } keyword extends: Indicates that you are making a new class that derives from an existing class.
  • 5. Types of Inheritance: On the basis of class, there can be three types of inheritance: Single Inheritance Multilevel Inheritance Hierarchical Inheritance Multiple & Hybrid - supported through interface only
  • 6.
  • 7.
  • 8. Why multiple inheritance is not supported in java? class A { void msg(){System.out.println("Hello");} } class B { void msg(){System.out.println("Welcome");} } class C extends A,B { //suppose if it were Public Static void main(String args[]){ C obj=new C(); obj.msg(); //Now which msg() method would be invoked? } }
  • 9. super keyword The super is a reference variable that is used to refer immediate parent class object. Usage of super Keyword super is used to refer immediate parent class instance variable. super() is used to invoke immediate parent class constructor. super is used to invoke immediate parent class method.
  • 10. Example: class Vehicle { int speed=50; } class Bike extends Vehicle { int speed=100; void display() { System.out.println(speed); //will print speed of Bike } public static void main(String args[]) { Bike b=new Bike(); b.display(); } } class Vehicle { int speed=50; } class Bike extends Vehicle { int speed=100; void display() { System.out.println(super.speed); //will print speed of Vehicle now } public static void main(String args[]) { Bike b=new Bike(); b.display(); } }
  • 11. super is used to invoke parent class constructor. class Vehicle { Vehicle() { System.out.println("Vehicle is created"); }} class Bike extends Vehicle { Bike() { super();//will invoke parent class constructor System.out.println("Bike is created"); } public static void main(String args[]) { Bike b=new Bike(); }}
  • 12. super can be used to invoke parent class method. class Person { void message(){System.out.println("welcome");} } class Student extends Person { void message() { System.out.println("welcome to java"); } void display() { message();//will invoke current class message() method super.message();//will invoke parent class message() method } public static void main(String args[]) { Student s=new Student(); s.display();}}
  • 13. Method Overriding in Java Having the same method in the subclass as declared in the parent class is known as method overriding. In other words, If subclass provides the specific implementation of the method i.e. already provided by its parent class, it is known as Method Overriding. Method Overriding is used for Runtime Polymorphism Rules for Method Overriding: method must have same name as in the parent class method must have same parameter as in the parent class. must be inheritance (IS-A) relationship.
  • 14. class Vehicle { void run() { System.out.println("Vehicle"); } } class Bike extends Vehicle { public static void main(String args[]) { Bike obj = new Bike(); obj.run(); } } class Vehicle { void run() { System.out.println("Vehicle is running"); } } class Bike extends Vehicle { void run() { System.out.println("Bike is running"); } public static void main(String args[]) { Bike obj = new Bike(); obj.run(); }
  • 15. Method Overloading Method Overriding 1) Method overloading is used to increase the readability of the program. Method overriding is used to provide the specific implementation of the method that is already provided by its super class. 2) method overloading is performed within a class. Method overriding occurs in two classes that have IS-A relationship. 3) In case of method overloading parameter must be different. In case of method overriding parameter must be same.