- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgood.java
More file actions
Latest commit
38 lines (35 loc) · 927 Bytes
/
Copy pathgood.java
File metadata and controls
38 lines (35 loc) · 927 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
packagejavatest;
publicclassgood{
publicstaticvoidmain (String[] args) {
ovverloado=newovverload();
ovverrideob= newovverride();
encape =newencap();
e.setNumber(999);
System.out.println("encap value "+e.getNumber());
o.num(8);
o.num(8,9);
ob.num(8);
}
}
classencap{// alt + shift +s for getter and setter or go to source for getter and setter
privateintnumber;
publicvoidsetNumber(inta) {
number = a;
}
publicintgetNumber() {
returnnumber;
}
}
classovverload{
publicvoidnum(inta){
System.out.println("overloading "+a);
}
publicvoidnum(inta, intb){
System.out.println("overloading "+a*b);
}
}
classovverrideextendsovverload{
publicvoidnum(inta){
System.out.println("overriding "+a*10);
}
}