Override

Override is one of  feature in OOP (Object Oriented Programming) that allows child use same name when create a method with parent even the method provide different implementation inside.

For example we create class ‘parent’ and ‘child’ that have same function, like code bellow:

Class Parent{

Function Size(){

return 3;

}

}

 

Class Child extends{

Function Size(){

return 2;

}

}

When we instantiation class parent and call function Size, we will get 3 but when we Instantiation class child and call function Size, we will get 2 even in code class Child extends class Parent

Iklan