Table of contents
No headings in the article.
Do you know what is method overriding?
Let me explain Hii I'm Kalimullah Ansari writing the blog over method overriding in java.
Method overriding in java is define as when child class contains same method as parent class with same parameter then child class override the parent class and execute.
Through method overriding we achieve run time polymorphism.
eg :-
// parent class or super class
class parent
{
Void greet ()
{
System.out.println("Good Morning");
}
}
// child class or sub class
class child extends parent
{
Void greet ()
{
System.out.println("Sweet. Good morning");
}
}
class override
{
public static void main(String. args[])
{
child C = new child (); class references
C.greet(); // here .dot operator is used to allocate memory
}
}