what is method overriding in oop code example

Example: what's method overriding

Overriding means same method name and same parameter, 
occur in different class that has inheritance relationship. 
we use method overriding to implement specific functionality to the method.

Example: get method
WebDriver driver = new ChromeDriver();
driver.get("URL") ==> opens the url from chrome

WebDriver driver = new FireFoxDriver();
driver.get("URL") ==> opens the url from Firefox

we can only override instance methods and method override 
takes place in sub class.
instance method that we are going to override cannot be private and final

Tags:

Java Example