-
Notifications
You must be signed in to change notification settings - Fork 0
/
j51AccessModifier2.java
34 lines (28 loc) · 1.19 KB
/
j51AccessModifier2.java
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
import com.company.AccessModifier;
import com.company.AccessModifier2;
// import from another class
class AccessModifier4 extends AccessModifier2{
}
class AccessModifier3 extends AccessModifier{
public void meth4(){
System.out.printf("\nPrint default Modifier int a = %d" ,a);
System.out.printf("\nPrint public Modifier int b = %d" ,b);
System.out.printf("\nPrint protected Modifier int c = %d" ,c);
// System.out.printf("\nPrint private Modifier int d = %d" ,d);
}
}
public class j51AccessModifier2 {
public static void main(String[] args){
AccessModifier AC = new AccessModifier();
//AC.meth1();
// we cannot acces frivate if importing the class
System.out.printf("\nPrint default Modifier int a = %d" ,AC.a);
System.out.printf("\nPrint public Modifier int b = %d" ,AC.b);
System.out.printf("\nPrint protected Modifier int c = %d" ,AC.c);
// System.out.printf("\nPrint private Modifier int d = %d" ,AC.d);
AccessModifier3 AC3 = new AccessModifier3();
AC3.meth4();
AccessModifier4 AC4 = new AccessModifier4();
System.out.println(AC4.b);
}
}