import
java.io.*;
class
grandParent {
int
grandParentAge;
String grandParentName;
grandParent(
int
grandParentAge, String grandParentName)
{
this
.grandParentAge = grandParentAge;
this
.grandParentName = grandParentName;
}
}
class
parent
extends
grandParent {
int
parentAge;
String parentName;
parent(
int
grandParentAge, String grandParentName,
int
parentAge, String parentName)
{
super
(grandParentAge, grandParentName);
this
.parentAge = parentAge;
this
.parentName = parentName;
}
}
class
child
extends
parent {
int
childAge;
String childName;
child(
int
grandParentAge, String grandParentName,
int
parentAge, String parentName,
int
childAge,
String childName)
{
super
(grandParentAge, grandParentName, parentAge,
parentName);
this
.childAge = childAge;
this
.childName = childName;
}
public
void
dispalyDetails()
{
System.out.println(
"Name of grand parent "
+ grandParentName +
" and he is "
+ grandParentAge +
" year old"
);
System.out.println(
"Name of parent "
+ parentName
+
" and he is "
+ parentAge
+
" year old"
);
System.out.println(
"Name of child "
+ childName
+
" and he is "
+ childAge
+
" year old"
);
}
}
class
GFG {
public
static
void
main(String[] args)
{
child obj =
new
child(
85
,
"Pan Singh"
,
39
,
"M.S.Dhoni"
,
5
,
"Ziva Dhoni"
);
obj.dispalyDetails();
}
}