-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prog5.java
86 lines (75 loc) · 2.02 KB
/
Prog5.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
public class Prog5
{
public static void main(String args[])
{
Parent1 ob1=new Parent1();
ob1.display();
ChildOne ob2=new ChildOne();
ob2.display();
ChildTwo ob3=new ChildTwo();
ob3.display();
}
}
class Parent1
{
int id;
String name,address;
Parent1()
{
id=23;
name="ABC";
address="KOLKATA";
}
public void display()
{
System.out.println(":PARENT CLASS:");
System.out.println("The name in Parent is:"+name);
System.out.println("The id in Parent is:"+id);
System.out.println("The address in Parent is:"+address);
}
}
class ChildOne extends Parent1
{
int marks;
int id;
String name,address;
ChildOne()
{
name=super.name;
id=super.id;
address =super.address;
marks=90;
}
public void display()
{
System.out.println(":CHILD1 CLASS:");
System.out.println("The name in child1 is:"+name);
System.out.println("The id in child1 is:"+id);
System.out.println("The address in child1 is:"+address);
System.out.println("The marks in child1 is:"+marks);
}
}
class ChildTwo extends Parent1
{
String qualification;
double salary;
int id;
String name,address;
ChildTwo()
{
name=super.name;
id=super.id;
address=super.address;
qualification="Graduate";
salary= 30000.00;
}
public void display()
{
System.out.println(":CHILD2 CLASS:");
System.out.println("The name in child2 is:"+name);
System.out.println("The id in child2 is:"+id);
System.out.println("The address in child2 is:"+address);
System.out.println("The qualification in child2 is:"+qualification);
System.out.println("The salary in child2 is:"+salary);
}
}