-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prog2.java
69 lines (59 loc) · 1.01 KB
/
Prog2.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
public class Prog2
{
public static void main(String args[])
{
Base ob=new Base();
ob.show();
Derived1 ob1=new Derived1();
ob1.show();
Derived2 ob2=new Derived2();
ob2.show();
Derived3 ob3=new Derived3();
ob3.show();
}
}
class Base
{
int x;
Base()
{
x=5;
}
public void show()
{
System.out.println("Base class x is:"+x);
}
}
class Derived1 extends Base
{
Derived1()
{
super();
}
public void show()
{
System.out.println("1st Derived class x is:"+x);
}
}
class Derived2 extends Base
{
Derived2()
{
super();
}
public void show()
{
System.out.println("2nd Derived class x is:"+x);
}
}
class Derived3 extends Base
{
Derived3()
{
super();
}
public void show()
{
System.out.println("3rd Derived class x is:"+x);
}
}