-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgood.java
More file actions
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
package javatest;
public class good{
public static void main (String[] args) {
ovverload o=new ovverload();
ovverride ob= new ovverride();
encap e =new encap();
e.setNumber(999);
System.out.println("encap value "+e.getNumber());
o.num(8);
o.num(8,9);
ob.num(8);
}
}
class encap{// alt + shift +s for getter and setter or go to source for getter and setter
private int number;
public void setNumber(int a) {
number = a;
}
public int getNumber() {
return number;
}
}
class ovverload{
public void num(int a){
System.out.println("overloading "+a);
}
public void num(int a, int b){
System.out.println("overloading "+a*b);
}
}
class ovverride extends ovverload{
public void num(int a){
System.out.println("overriding "+a*10);
}
}