1Method Overloading:
2Access modifier can be same or different,
3Return-Type can be same or different,
4Parameters MUST be different, Method name MUST be same,
5any method can be overloaded
6
7Method Overriding:
8After a method is inherited it is possible to change
9the implantation of the method in the child class.
10This concept is called overriding.
11Method name, Parameter, and Return-Type MUST be same
12access modifier MUST be same or more visible,
13MUST happen in the sub class,
14ONLY the instance methods can be overridden
15@Override annotation MUST be applicable.
16Static and Constructor cannot be override.
17We can use the @Override annotation before the method
18to declare the overriding.
19EXAMPLE: get method WebDriver driver = new ChromeDriver();
20driver.get("URL") ==> opens the url from chrome
21
1Overriding means same method name and same parameter,
2occur in different class that has inheritance relationship.
3we use method overriding to implement specific functionality to the method.
4
5Example: get method
6WebDriver driver = new ChromeDriver();
7driver.get("URL") ==> opens the url from chrome
8
9WebDriver driver = new FireFoxDriver();
10driver.get("URL") ==> opens the url from Firefox
11
12we can only override instance methods and method override
13takes place in sub class.
14instance method that we are going to override cannot be private and final
1//https://www.geeksforgeeks.org/overloading-in-java/
2// Java program to demonstrate working of method
3// overloading in Java.
4
5public class Sum {
6
7 // Overloaded sum(). This sum takes two int parameters
8 public int sum(int x, int y)
9 {
10 return (x + y);
11 }
12
13 // Overloaded sum(). This sum takes three int parameters
14 public int sum(int x, int y, int z)
15 {
16 return (x + y + z);
17 }
18
19 // Overloaded sum(). This sum takes two double parameters
20 public double sum(double x, double y)
21 {
22 return (x + y);
23 }
24
25 // Driver code
26 public static void main(String args[])
27 {
28 Sum s = new Sum();
29 System.out.println(s.sum(10, 20));
30 System.out.println(s.sum(10, 20, 30));
31 System.out.println(s.sum(10.5, 20.5));
32 }
33}
1Overriding means same method name and same parameter,
2occur in different class that has
3inheritance relationship.
4we use method overriding to implement
5specific functionality to the method.
6
7Examples are get and navigate methods
8of different drivers in Selenium .
9
10Example: get method
11WebDriver driver = new ChromeDriver();
12driver.get("URL") ==> opens the url from chrome
13
14WebDriver driver = new FireFoxDriver();
15driver.get("URL") ==> opens the url from Firefox
16
17we can only override instance methods and method override
18takes place in sub class.
19instance method that we are going to override cannot be private and final
20Example: get method
21WebDriver driver = new ChromeDriver();
22driver.get("URL") ==> opens the url from chrome
23
24WebDriver driver = new FireFoxDriver();
25driver.get("URL") ==> opens the url from Firefox
26
27we can only override instance methods and method override
28takes place in sub class.
29instance method that we are going to
30override cannot be private and final
1Overriding means same method name and same parameter,
2occur in different class that has
3inheritance relationship.
4we use method overriding to implement
5specific functionality to the method.
1using method-override in your index.js
21. npm install method-override --save
32. var methodOverride = require("method-override");
43. app.use(methodOverride("_method"));
5//'_method' is what methodOverride will look for
6method override in your UPDATE route:
7* <form action = "/campgrounds/<%=campground._id%>/edit?_method=PUT"
8 method = "POST">
9and EDIT routes:
10