-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathOverloadingDemo.java
More file actions
42 lines (32 loc) · 908 Bytes
/
OverloadingDemo.java
File metadata and controls
42 lines (32 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class ShopSearch{
void search(double price) {
System.out.println("Price "+price);
}
public String search(String brand) {
System.out.println("Brand "+brand);
return "";
}
protected int search(String brand, double price) throws ArrayIndexOutOfBoundsException {
System.out.println("Brand "+brand+" Price "+price);
return 0;
}
void search(double price, String brand) throws NullPointerException {
System.out.println("Price "+price +" Brand "+brand);
}
}
class Shop2 extends ShopSearch{
void search(double price, String brand, double dis) {
System.out.println("Price "+price +" Brand "+brand+" Dis "+dis);
}
}
public class OverloadingDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Shop2 shop = new Shop2();
shop.search(9999,"Nike",7);
shop.search(9000);
shop.search("Nike");
shop.search(9000,"Nike");
shop.search("Nike",9000);
}
}