Method is a collection of statements that perform some specific task and return the result. Override means two methods having same name but doing different tasks. It means that one of the methods overrides another method. If there is any method in the superclass and a method with the same name in its subclass, then by executing these methods, method of the corresponding class will be executed.
Welcome to GeeksForGeeks
In above Example, Execution of a on the object of A printed Geeks from the a method defined in the A class whereas, execution of a on the object of B printed Welcome to GeeksForGeeks from the a method defined in the B class. It is very useful because it prevents us from making methods with different names and remembering that all. The method a in class B overrides the method a in class A.
Big box area is : 300
In above example, The method getArea in class BigBox overrides the method getArea in class Box.
- Ruby Float to_r() method with example
- Ruby | String inspect Method
- Ruby | String hex Method
- Ruby | String include? Method
- Ruby | Integer > method
- Ruby | Date <=>() method
- Ruby | Date + method
- Ruby | Complex + method
- Ruby Float coerce() method with example
- Ruby | String delete_suffix! Method
- Ruby | String dump Method
- Ruby | String each_byte Method
- Ruby | Matrix == method
- Ruby | Matrix ** method
- Ruby | Rational * method
- Ruby | Set >= method
- Ruby Float to_d() - BigDecimal method with example
- Ruby | String * Method
- Ruby | String + Method
- Ruby | String << Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.