OVERRIDING
whenever method of parent class is implemented by its child classes used same type and argument that method called us overriden method and that process called overriding
example
class Parent
{
public void display()
{
System.out.println("display method is called");
}
}
class Child
{
// overriden method
public void display()
{
System.out.println("display method is called");
}
NOTE
1)modifier will change with which have higher priorty in overriden method
like
class Parent
{
protected void display()
{
System.out.println("display method is called");
}
}
class Child
{
// overriden method
public void display()
{
System.out.println("display method is called");
}
public> protected>default>private
2) private type method is not overriden.
3) it is use runtime polymorphism .
whenever method of parent class is implemented by its child classes used same type and argument that method called us overriden method and that process called overriding
example
class Parent
{
public void display()
{
System.out.println("display method is called");
}
}
class Child
{
// overriden method
public void display()
{
System.out.println("display method is called");
}
NOTE
1)modifier will change with which have higher priorty in overriden method
like
class Parent
{
protected void display()
{
System.out.println("display method is called");
}
}
class Child
{
// overriden method
public void display()
{
System.out.println("display method is called");
}
public> protected>default>private
2) private type method is not overriden.
3) it is use runtime polymorphism .
Comments
Post a Comment