File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Area {
2
+ int len ,bre ;
3
+
4
+ void getValue (){
5
+ len = 12 ;
6
+ bre = 8 ;
7
+ }
8
+
9
+ void getValue (int l ){
10
+ len = bre = l ; // In other words SQUARE
11
+ }
12
+
13
+ void getValue (int l , int b ){
14
+ len = l ;
15
+ bre = b ;
16
+ }
17
+
18
+ void display (){
19
+ System .out .println ("Area = " + len * bre );
20
+ }
21
+ }
22
+
23
+ class MethodOverloadingDemo {
24
+ public static void main (String args []){
25
+
26
+ Area a1 = new Area ();
27
+ a1 .getValue (); // It will call the method with 0 parameters
28
+ a1 .display ();
29
+
30
+ Area a2 = new Area ();
31
+ a2 .getValue (7 ); // It will call method with 1 parameter
32
+ a2 .display ();
33
+
34
+ Area a3 = new Area ();
35
+ a3 .getValue (20 ,15 ); // It will call method with 2 parameters
36
+ a3 .display ();
37
+
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments