Inheritance in Java is achieved by the keyword extends.
A true Guru is a God-realized spiritual teacher.
A Guru is in union (yoga) with the divine consciousness of God… a Guru is an extension of God.
This example shows the Guru inheriting all of God’s divine properties.
The Guru’s disciples inherit the Guru’s properties and God’s properties, from the Guru.
Java NetBeans project Inheritance:
/*
keyword extends allows a class to inherit the fields and methods of another class
*/
class God {
private String god;
public String getGod() {
return god;
}
public void setGod(String newGod) {
god = newGod;
}
}
class Guru extends God {
private String guru;
public String getGuru() {
return guru;
}
public void setGuru( String newGuru) {
guru = newGuru;
}
}
class Disciple1 extends Guru {
private String disciple1;
public String getDisciple1() {
return disciple1;
}
public void setDisciple1(String newDisciple1) {
disciple1 = newDisciple1;
}
}
class Disciple2 extends Guru {
private String disciple2;
public String getDisciple2() {
return disciple2;
}
public void setDisciple2(String newDisciple2) {
disciple2 = newDisciple2;
}
}
public String god() {
God g = new God();
g.setGod(“God superClass”);
String godReturn;
godReturn = (g.getGod() + “\r\n”);
return godReturn;
}
public String guru() {
Guru h = new Guru();
h.setGod(“God superClass”);
h.setGuru(“Guru class inherits God superClass”);
String guruReturn;
guruReturn = (h.getGod() + “\r\n” + h.getGuru() + “\r\n”);
return guruReturn;
}
public String disciple1() {
Disciple1 m = new Disciple1();
m.setGod(“God superClass”);
m.setGuru(“Guru class inherits God superClass”);
m.setDisciple1(“Disciple1 class inherits Guru class”);
String disciple1Return;
disciple1Return = (m.getGod() + “\r\n” + m.getGuru() + “\r\n” + m.getDisciple1() + “\r\n”);
return disciple1Return;
}
public String disciple2() {
Disciple2 m = new Disciple2();
m.setGod(“God superClass”);
m.setGuru(“Guru class inherits God superClass”);
m.setDisciple2(“Disciple2 class inherits Guru class”);
String disciple2Return;
disciple2Return = (m.getGod() + “\r\n” + m.getGuru() + “\r\n” + m.getDisciple2() + “\r\n”);
return disciple2Return;
}