8.9 Polymorphism | OOPs | Method Overriding

preview_player
Показать описание
For code click here

Polymorphism in java is a concept by which we can perform a single action by different ways.
Polymorphism is derived from 2 greek words: poly and morphs.
The word "poly" means many and "morphs" means forms.
So polymorphism means many forms.

There are two types of polymorphism in java:
compile time polymorphism and
runtime polymorphism.
We can perform polymorphism in java by method overloading and method overriding.

The implementation in the subclass overrides (replaces) the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class

Method overriding is used to provide specific implementation of a method that is already provided by its super class.

Follow on Facebook:

Subscribe to our other channel:
Telusko Hindi :
Рекомендации по теме
Комментарии
Автор

Method overloading and overriding, you made it absolute clear! Thanks so much

evandawson
Автор

Really you teach very very well. Thanks. Pls tell me real time example of constructor IN application

rasikadeshpande
Автор

can we call super.show() from the same method in sub

divyeshkumarbalar
Автор

do you think as i get job after learning java

rohitkumar-buzn
Автор

Where we should have to use this overriding

yashureddy
Автор

sir, in method overriding cases you haven;t taken any example with method with parameter, if this could have included then every concept was fine anyway it;s good video

siddharthbhandari
Автор

did u do any for recursion ? if not please do it 

Some
Автор

i got an error when tried to call from main method by creating of object of b class
public class Test2016 {

public static void main(String[] args) {

b obj= new b(); : Here i got an error (Exception in thread "main" java.lang.Error: Unresolved compilation problem:
No enclosing instance of type Test2016 is accessible. Must qualify the allocation with an enclosing instance of type Test2016 (e.g. x.new A() where x is an instance of Test2016).

at
)


}

class a {

public void eat(){

System.out.println("a is eting");
}
}

class b extends a{

public void eat(){


}
}

}

nareshshama
Автор

sir, why is it called dynamic binding?

meenakshitomar
Автор

Where we should have to use this overriding

yashureddy
Автор

Where we should have to use this overriding

yashureddy