Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Method Overriding in Java

DEV Community·SILAMBARASAN A·27 days ago
#CPIA5v78
Reading 0:00
15s threshold

Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes. When a method in a subclass has the same name, same parameters or signature, and same return type(or sub-type) as a method in its super-class, then the method in the subclass is said to override the method in the super-class. Method overriding is one of the way by which java achieve Run Time Polymorphism. Usage of Java Method Overriding Method overriding is used to provide the specific implementation of a method which is already provided by its superclass. Method overriding is used for runtime polymorphism. Rules for Java Method Overriding The method must have the same name as in the parent class. The method must have the same parameter as in the parent class. There must be an IS-A relationship (inheritance). What Cannot Be Overridden?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More