-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo4.java
More file actions
102 lines (73 loc) · 2.35 KB
/
Demo4.java
File metadata and controls
102 lines (73 loc) · 2.35 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// class Math {
// public int add(int num1, int num2) {
// int sum = num1 + num2;
// return sum;
// }
// }
// =============================================
// =============================================
// class Store {
// public void music() {
// System.out.println("Play the Music");
// }
// public String buyPen(int price) {
// if (price >= 5)
// return "You Can Buy a Pen";
// return "You Can't Buy a Pen";
// }
// }
// =============================================
// =============================================
// class overLoading {
// public int add(int num1, int num2) {
// return num1 + num2;
// }
// public int add(int num1, int num2, int num3) {
// return num1 + num2 + num3;
// }
// public double add(double num1, int num2) {
// return num1 + num2;
// }
// }
// =============================================
// =============================================
// class stackHeap {
// int c;
// public int add(int a, int b) {
// return a + b;
// }
// }
public class Demo4 {
public static void main(String[] args) {
// 13. Class & Object Theory In Java
// Class
// int a = 5;
// int b = 5;
// Math calc = new Math();
// int result = calc.add(a, b);
// System.out.println(result);
// =============================================
// =============================================
// 14. Methods In Java
// Store obj = new Store();
// obj.music();
// String str = obj.buyPen(5);
// System.out.println(str);
// =============================================
// =============================================
// 15. Method Overloading In Java
// overLoading obj = new overLoading();
// int r1 = obj.add(5, 5);
// int r2 = obj.add(5, 7, 2);
// int r3 = obj.add(5, 8);
// System.out.println(r1);
// System.out.println(r2);
// System.out.println(r3);
// =============================================
// =============================================
// 16. Stack & Heap In Java
// stackHeap obj = new stackHeap();
// int result = obj.add(5, 6);
// System.out.println(result);
}
}