Polymorphism & Overloading & Overriding

In Java, a method signature is the method name and the number and type of its parameters. Return types and thrown exceptions are not considered to be a part of the method signature.

What is Polymorphism

Polymorphism is an important Object oriented concept and widely used in Java and other programming language.

It is supported along with other concept like Abstraction, Encapsulation and Inheritance.

It advices use of common interface instead of concrete implementation while writing code.

Java has excellent support of polymorphism in terms of Inheritance, method overloading and method overriding.

Method overriding allows Java to invoke method based on a particular object at run-time instead of declared type while coding.

Method overloading and method overriding in Java is two important concept in Java which allows Java programmer to declare method with same name but different behavior. Method overloading and method overriding is based on Polymorphism in Java.

What is Method Overloading

In case of method overloading, method with same name co-exists in same class but they must have different method signature.

Resolved during compile time, using static binding.

Can overload static, final and private methods.

Method signature must be different.

 

What is Method Overriding

In case of method overriding, method with same name is declared in derived class or sub class.

Resolved at runtime, using dynamic binding.

Cannot override static, final and private methods.

Both name and signature of method must remain same.

 

转载于:https://www.cnblogs.com/ireneyanglan/p/4951339.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值