-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverloadVsOverride.java
More file actions
43 lines (43 loc) · 893 Bytes
/
OverloadVsOverride.java
File metadata and controls
43 lines (43 loc) · 893 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
43
public class OverloadVsOverride
{
public static void main(String[] Soylu)
{
Human_ h1=new Human_("kelile", 89);
Student_ s1=new Student_("Dimne",56,850);
h1.growe();
h1.growe(5);
s1.growe();
System.out.println(h1.age+" "+s1.schoolerShip);
}
}
class Human_
{
String name;
int age;
Human_(String name, int age)
{
this.name=name;
this.age=age;
}
void growe()
{
age++;
}
void growe(int a)//! overload same methode name havin diffarent parameter list
{
age+=a;
}
}
class Student_ extends Human_
{
Student_(String name, int age, int schoolerShip) {
super(name, age);
this.schoolerShip=schoolerShip;
}
int schoolerShip;
@Override
void growe()//! override same method but in child class
{
schoolerShip+=age;
}
}