0% found this document useful (0 votes)
43 views3 pages

Students Should Understand Concept of Dispatch Methodfinal Method and Use of Super .

Method overloading allows defining methods with the same name but different parameters, while method overriding defines a method in the subclass with the same signature as the parent class method that replaces the parent method behavior. An example of method overloading shows adding methods for integers, strings, and doubles. An example of method overriding shows a child class replacing the parent class add method to also print the child's field. The key takeaway is students should understand the difference between overloading and overriding.

Uploaded by

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

Students Should Understand Concept of Dispatch Methodfinal Method and Use of Super .

Method overloading allows defining methods with the same name but different parameters, while method overriding defines a method in the subclass with the same signature as the parent class method that replaces the parent method behavior. An example of method overloading shows adding methods for integers, strings, and doubles. An example of method overriding shows a child class replacing the parent class add method to also print the child's field. The key takeaway is students should understand the difference between overloading and overriding.

Uploaded by

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

Template: Study Material

Insert the details within the < quotes >


<CO>: <22412>: <Java Programming>: <Inheritance >: <LO2a>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >

Key words Learning Objective: Diagram/ Picture


Super,Inheritance,parent class,sub Students should understand Differentiate between
class,child class, overloading and overriding

Key Questions Concept Map

What do you mean by method


overloading?
What do you mean by method
overriding?
Explanation of Concept: Key Definitions/
Method Overloading: Formulas
 Method Overloading means to define
different methods with the same name but
different parameters lists and different
definitions.
 It is used when objects are required to
perform similar task but using different input
parameters that may vary either in number
or type of arguments.
 Overloaded methods may have different
return types.
 Method overloading allows user to achieve
the compile time polymorphism.
Method Overloading:
 There may be situation when we want an
object to respond to the same method but
have different behavior when that method is
called.
 This is possible by defining a method in the
subclass that has the same name, same
arguments and same return type as a method
in the superclass.
 Then, when that method is called, the
method defined in the subclass is invoked
and executed instead of the one in the
superclass. This is known as overriding.
 In overriding return types and constructor
parameters of method should match.
Solved word Problem
Example of method overloading Example of method overriding:
class Sample class A
{ {
int addition(int i, int j) int i;
{ returni + j ; } A(int a, int b)
String addition(String s1, String s2) {
{ return s1 + s2; } i=a+b;
double addition(double d1, double d2) }
{ return d1 + d2; } void add()
} {
class AddOperation System.out.println(“Sum of a & b is=” +i);
{ }
public static void main(String args[]) }
{ class B extends A
Sample sObj = new Sample(); {
System.out.println(sObj.addition(1,2)); int j;
System.out.println(sObj.addition("Hello B(int a, int b, int c)
","World")); {
System.out.println(sObj.addition(1.5,2.2)); super(a,b); j=a+b+c;
} }
} void add()
{
super.add();
System.out.println(“Sum of a, b & c”+j);
}
}
class MethodOverride
{
public static void main(String args[])
{
B b=new B(10,20,30); Link to YouTube/
Application of Concept/ Examples in real life: OER/ video
The real life example of inheritance is child and
parents, all the properties of father are inherited by his
son.

Key Take away from this LO2a: students should differentiate between method overloading and overriding concept

You might also like