-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCWH_32_Method_OverLoading.java
50 lines (39 loc) · 1.42 KB
/
CWH_32_Method_OverLoading.java
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
43
44
45
46
47
48
49
50
public class CWH_32_Method_OverLoading {
static void foo(){
System.out.println("Good Morning bro!");
}
static void foo(int a){
System.out.println("Good Morning "+a+" bro!");
}
static void foo(int a, int b){ // a & b are PARAMETERS
System.out.println("Good Morning "+a+" bro!");
System.out.println("Good Morning "+b+" bro!");
}
static void change(int a){
a=98;
}
static void change2(int [] arr){
arr[0] = 98;
}
static void tellJoke()
{
System.out.println("I invented a new word!\n" + "Plagiarism!");
}
public static void main(String[] args) { // MAIN METHOD
tellJoke();
// Case 1 : Changing the Integer
//int x=45;
//change(x);
//
// System.out.println("The value of x after running change is: "+x);
// Case 2 : Changing the Array
//int [] marks = {52, 73, 77, 89, 98, 94};//it creates ARRAY OBJECT & here MARKS is a REFERENCE
//change2(marks);//Here we are passing the object/REFERENCE
//System.out.println("The value of x after running change is: "+marks[0]);
// METHOD OVERLOADING (Only parameters can be changed) (can't be performed by changing the return type)
foo();
foo(3000); // 3000 is ARGUMENT
// ARGUMENTS ARE ACTUAL VALUES
foo(3000,4000);
}
}