forked from mohammedabdulbari/Java-SE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyPack1.java
54 lines (44 loc) · 786 Bytes
/
MyPack1.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package mypack1;
class Demo1
{
int a=10;
//private.
public int b=20;
protected int c=30;
public int d=40;
public void display()
{
System.out.println(a+b+c+d);
}
}
/*Public class Demo2()
{
Demo1 d=new Demo1();
public void show()
{
System.out.println(d.a+d.b+d.c+d.d);
}
}*/
class Demo3 extends Demo1
{
Demo1 d=new Demo1();
public void show()
{
System.out.println(d.a+d.b+d.c+d.d);
}
}
class Demo4 extends Demo1
{
public void show()
{
System.out.println(a+b+c+d);
}
}
public class MyPack1 {
public static void main(String[] args)
{
Demo1 d1=new Demo1();
d1.display();
System.out.println(d1.a+d1.b+d1.c+d1.d);
}
}